问题
I'm trying to create a pdf using Python's reportlab module.
I generated a png with matplotlib and saved it in the pdf file using report labs canvas.drawImage method.
My problem is that the generated png file is very fuzzy. I specified the size in inches with plt.figure(figsize=(20,10)) and saved the picture with the plt.savefig method.
This works out perfectly (except the fuzzy quality of the picture).
But when I increase the dpi within the savefig method the size of the picture increases.
Is there any way to improve the dpi without changing the picture size.
Or is there a way to resize it to the predefined values?
Thanks!
回答1:
f = df.plot()
fig = f.get_figure()
fig.set_size_inches((2,2))
fig.savefig('C:/temp/foo.png', bbox_inches='tight', dpi=1500)
来源:https://stackoverflow.com/questions/53821417/increase-dpi-in-matplotlib-chart-without-changing-its-size