1
我想在繪圖窗口關閉後根據用戶選擇更改繪圖標題。如何在繪圖窗口在Python中關閉後設置繪圖標題
ax = pd.rolling_mean(dataToPlot_plot[startTime:endTime][['plotValue']],mar).plot(linestyle='-', linewidth=3, markersize=9, color='#FECB00')
ax.legend().set_visible(False)
titObj = plt.title('Data Plot - '+"\n", fontsize=13)#plot title
plt.show()#showing the plot
fig = ax.get_figure()
fig.set_size_inches(12, 6)
fig.savefig(savePlot)
現在我需要改變的情節標題動態基礎上對劇情的用戶選擇,並保存它...
ax = pd.rolling_mean(dataToPlot_plot[startTime:endTime][['plotValue']],mar).plot(linestyle='-', linewidth=3, markersize=9, color='#FECB00')
ax.legend().set_visible(False)
titObj = plt.title('Data Plot - '+"\n", fontsize=13)#plot title
plt.show()#showing the plot
curVal = ax.get_xlim()
stdate = int(curVal[0])
endate = int(curVal[1])
difdate = endate - stdate
fig = ax.get_figure()
if stdate > 0 and endate > 0:
if difdate > 365:
newplotTitle = 'Data Plot - Since from start'
elif difdate > 28 and difdate < 365:
newplotTitle = 'Data Plot - Past Month'
elif difdate < 28:
newplotTitle = 'Data Plot - Past Days'
plt.title(newplotTitle+"\n", fontsize=13)#plot title
fig.set_size_inches(12, 6)
fig.savefig(savePlot)
新的變化不與舊的標題修改,有什麼其他的方法來解決這個問題... 在此先感謝...
謝謝@Joe Kington,很好的幫助......它的工作,也試圖用「fig.suptitle(newplotTitle +」\ n「,fontsize = 13)#plot title」正在工作。感謝您的時間和幫助 –