0

I want to save an image plotted with matplotlib. For that, I use the function savefig which has different parameters. The problem is that when I saved the image, this function add additional white pixel.

In short, I would like to save the image I draw with the original size. In other words, if the data I draw has a dimension of 1000x560, I save the image with those dimensions without additional white parts. Thus in this way a pixel of the saved image coincides with the pixel that the figure of matplotlib can see.

I'm using python 2.7

Can anyone help please?

Thanks

  • Please refer to this link. https://stackoverflow.com/questions/9622163/save-plot-to-image-file-instead-of-displaying-it-using-matplotlib – WenJuan Mar 13 '19 at 09:15
  • 1
    Possible duplicate of [Save plot to image file instead of displaying it using Matplotlib](https://stackoverflow.com/questions/9622163/save-plot-to-image-file-instead-of-displaying-it-using-matplotlib) – Varada Mar 13 '19 at 09:16

1 Answers1

0
from matplotlib import pyplot as plt
plt.savefig('foo.png', bbox_inches='tight')
Jibin Mathew
  • 4,816
  • 4
  • 40
  • 68