Matplotlib.pyplot 把画图保存为图片

在plt.show()之前执行plt.savefig()函数即可。

简单例子:

import matplotlib.pyplot as plt

x=[1,2,3,4,5]

y=[10,5,15,10,20]

plt.plot(x,y,'ro-',color='blue')

plt.savefig('testblueline.jpg')

plt.show()

猜你喜欢

转载自www.cnblogs.com/lijavasy/p/10669053.html