最近幾天我一直在保存matplotlib圖的問題,在代碼工作正常前三天,並通過代碼進行的更改保存繪圖,但現在變化(縮放圖)不是保存,而是保存原樣顯示的情節,之後所做的任何更改都不反映使用保存命令,不知道爲什麼?如何在放大繪圖後保存繪圖
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現在繪圖窗口的外觀
所有繪圖窗口的配置按鈕都從下往上移動,這種改變是否隻影響繪圖或也影響編碼?請幫我解決這個問題...
在此先感謝。
沒有足夠的信息在這裏瞭解你的問題。 – tacaswell
感謝@tcaswell,如何在放大情節後保存劇情?該代碼在兩天前工作...場景1:之前,我繪製圖形並關閉它的代碼將圖形保存爲.jpg,並且還保存了該圖形,即使出現當前更改,例如圖形放大...場景2:現在當我繪製圖形並關閉它保存圖,但是當我放大並關閉它時,圖不會保存當前選擇我不明白爲什麼,請對此提出您的建議...謝謝 –
Thanks @tcaswell [1]舊外觀圖窗口(i.imgur.com/9O4ScmX.png)[2]新外觀圖窗口(i.imgur.com/ogKJiPo.png)。我想知道,情節中的變化是否會影響我以前的代碼?如何在放大代碼後保存圖表,感謝您的幫助... –