0

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!

j. DOE
  • 238
  • 1
  • 2
  • 15

1 Answers1

2
f = df.plot()
fig = f.get_figure()
fig.set_size_inches((2,2))
fig.savefig('C:/temp/foo.png', bbox_inches='tight', dpi=1500)
jason m
  • 6,519
  • 20
  • 69
  • 122
  • Hi, thanks for the quick response. Unfortunately it doesn't work. The picture of the chart is still increasing in size when I increase the dpi. If I use your method and set it to 100 instead of 1500 I get the same resulst as before. – j. DOE Dec 18 '18 at 06:34
  • https://matplotlib.org/api/_as_gen/matplotlib.pyplot.savefig.html - that is not what should happen. – jason m Dec 18 '18 at 14:31