I can't reproduce the same plot quality shown with matplotlib plt.show()
in plt.savefig()
. I have followed this thread here but no luck. As indicated there, I have created anew the matplotlibrc.template
in the newly created .matplotlib
folder, and changed the suggested parameters. I have also tried to change the dpi value, from some very high input manually selected (e.g., dpi=1200
) to that passed from the original figure (dpi=fig.dpi
). I have also tried to change the resulting extension of the save files: eps/png/pdf (eps would be preferrable). None of this really fixed the issue. I suspect there might be some conflicts between settings but I am not sure where to look for.
Asked
Active
Viewed 100 times
0

Py-ser
- 1,860
- 9
- 32
- 58
-
I am not sure if this would solve the problem, but you can also try to save the picture to a numpy array first and then convert it to a PIL image and then save. (Assuming the problem is with matplotlib.) This is how to make the conversion to numpy array: https://stackoverflow.com/questions/21939658/matplotlib-render-into-buffer-access-pixel-data and this is how to convert from numpy array to PIL image: https://stackoverflow.com/questions/10965417/how-to-convert-a-numpy-array-to-pil-image-applying-matplotlib-colormap. To save the PIL image there is a PIL function called `.save()`. – p479h Jun 24 '20 at 07:19
-
@p479h thanks. I have doing a similar workaround, by saving the image plotted by `show()`, but this is not the solution I had in mind. – Py-ser Jun 24 '20 at 15:40
-
Sorry. I can't think of much else. – p479h Jun 24 '20 at 22:54