When saving my Seaborn heatmap plot with plt.savefig(sample.pdf), my colorbar frame gets distorted.
This distortion does not appear when using plt.show()
Is there a way to correct this?
CodePudding user response:
In the usual case, with more than 50 colors in the colormap, the colorbar pcolormesh output is rasterized to eliminate the artifacts that would otherwise appear when the pdf is rendered.
Rasterizing at low dpi gives bad resolution, so the colorbar interior doesn't coincide with the vector graphics of its outline.
Try to boost the dpi resolution argoument.
plt.savefig('your_file.pdf', dpi=200)