在过去的几天里,我一直面临着保存matplotlib图形的问题,前三天代码工作正常,并保存了通过代码所做的更改绘图,但现在的更改(缩放绘图)不是保存,而是它保存,因为当绘图显示后所做的任何更改都没有反映使用save命令,不知道为什么?
ax = pd.rolling_mean(dataToPlot_plot[startTime:endTime][['plotValue']],mar).plot(linestyle='-', linewidth=3, markersize=9, color='#FECB00')
ax.legend().set_visible(False)
plt.show()#showing the plot
fig = ax.get_figure()
fig.set_size_inches(12, 6)#setting the size of the plot, to fix in the PDF file
fig.savefig('graph1.jpg')#saving the plot即使我调用了一个函数,新更改的绘图也不会被保存...
def callmeto_plot()
ax = pd.rolling_mean(dataToPlot_plot[startTime:endTime][['plotValue']],mar).plot(linestyle='-', linewidth=3, markersize=9, color='#FECB00')
ax.legend().set_visible(False)
plt.show()#showing the plot
fig = ax.get_figure()
return fig
fig = callmeto_plot()
fig.set_size_inches(12, 6)
fig.savefig('graph1.jpg')如何通过代码保存绘图(缩放后的绘图)?
注意:我注意到绘图窗口的外观也发生了变化。
之前的1绘图窗口外观
现在的2绘图窗口外观
所有plot window configuration (绘图窗口配置)按钮都从下到上移动,此更改是仅影响绘图中的还是也会影响编码?请帮我解决这个问题。
提前谢谢。
发布于 2014-07-17 04:14:05
您可以将所有绘图更改代码移到plt.show()上,然后从弹出窗口手动保存图形。左下角最右边的图标保存当前显示的图形
更好的是,您可以使用plt.axis([xStart, xFinish, yBottom, yTop])或ax.set_xlim(), ax.set_ylim
https://stackoverflow.com/questions/24778926
复制相似问题