自动保存图表

import matplotlib.pyplot as plt

x_values = range(1,1001)
y_values = [x ** 2 for x in x_values]
fig,ax = plt.subplots()
ax.scatter(x_values,y_values,s=100,c=y_values,cmap=plt.cm.Blues)
ax.axis([0,1100,0,1100000])
plt.savefig('squares_plot.png',bbox_inches='tight')    # show()替换savefig(),squares_plot.png为图表文件名字,bbox_inches指定将图表空白区域剪掉

  

原文地址:https://www.cnblogs.com/leisurelyRD/p/14531130.html