用python的matplotlib绘图后保存图形

用python的matplotlib可以绘制各种图形,图形绘制完成后保存有以下两种方式:


1. 用savefig

impotrt  matplotlib

matploylib.pyplot.savefig("my picture.png")
#注意这个命令要用在命令matplotlib.pyplot.show()之前,不然只会保存一张空白图片

2.绘图完成后,加上以下代码

fig = matplotlib.pyplot.gcf()  
fig.savefig('my picture.png')



posted @ 2017-07-17 16:33  banlucainiao  阅读(127)  评论(0)    收藏  举报