I would like to remove the lines that separate the cells in a saved pdf. I tried setting the linewidth=0.0, but the lines are still showing.
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
data = pd.DataFrame(np.arange(10*10).reshape(10,10))
fig, ax = plt.subplots()
ax = sns.heatmap(data,linewidths=0.0)
fig.savefig('stackoverflow_lines.pdf')
The image is a screen capture of the resulting pdf.
This is an issue only when saving to PDF files, if you use something like a PNG then it will work fine. A Github Issue has been raised here with the developers.
In the meantime, the developer mwaskom has found a fix where you can add rasterized=True
to the seaborn.heatmap
function which fixes the issue. Your code then becomes:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
data = pd.DataFrame(np.arange(10*10).reshape(10,10))
fig, ax = plt.subplots()
ax = sns.heatmap(data,linewidths=0.0, rasterized=True)
fig.savefig('stackoverflow_lines.pdf')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.