我是一個新手,並試圖在我的圖表上設置兩條線,分別爲.fill_between()
。我試過了我能想到的一切,以確保底層數據是正確的,但每次我繪製這個圖時,.fill_between()
在x軸上出現的一個值比它應該是短的。 這裏是我的代碼:Matplotlib .fill_between()抵消-1 -1
df_combo = pd.read_csv('MySampleData.csv')
max_hist_temps = df_combo['hist_max']
min_hist_temps = df_combo['hist_min']
plt.figure()
plt.plot(max_hist_temps, '-.r'
, min_hist_temps, '-.b'
)
plt.gca().fill_between(range(len(max_hist_temps)),
min_hist_temps, max_hist_temps,
facecolor='blue',
alpha = 0.25)
ax = plt.gca()
ax.axis([0,364,-45,45])
plt.show()
下面是一些樣本數據:
Day_of_Year hist_min hist_max
1 -16 15.6
2 -26.7 13.9
3 -26.7 13.3
4 -26.1 10.6
5 -15 12.8
6 -26.6 18.9
7 -30.6 21.7
8 -29.4 19.4
9 -27.8 17.8
感謝你的幫助, 我