[英]How to save plot after the plot is zoomed
最近幾天,我在保存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現在繪制窗口外觀
所有繪圖窗口配置按鈕都從底部移到頂部,此更改是否只影響繪圖或編碼? 請幫我解決這個問題...
提前致謝。
您可以將所有繪圖更改代碼plt.show()
上方,然后從彈出窗口中手動保存圖形。 左下方最右邊的圖標會將當前圖形保存為當前顯示的狀態
更好的是,您可以使用plt.axis([xStart, xFinish, yBottom, yTop])
或ax.set_xlim(), ax.set_ylim
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.