简体   繁体   English

如何保存用Matplolib 1.5绘制的图像

[英]How to save an image plotted with matplolib 1.5

I want to save an image plotted with matplotlib. 我想保存用matplotlib绘制的图像。 For that, I use the function savefig which has different parameters. 为此,我使用具有不同参数的功能savefig。 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. 换句话说,如果我绘制的数据的尺寸为1000x560,则我将使用这些尺寸保存图像,而无需添加其他白色部分。 Thus in this way a pixel of the saved image coincides with the pixel that the figure of matplotlib can see. 因此,以这种方式保存的图像的像素与matplotlib图形可以看到的像素重合。

I'm using python 2.7 我正在使用python 2.7

Can anyone help please? 有人可以帮忙吗?

Thanks 谢谢

from matplotlib import pyplot as plt
plt.savefig('foo.png', bbox_inches='tight')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM