2016-04-16 19 views
0

之間考慮到與matplotlib 1.1.1產生以下圖表:差分XLIM/ylim和Axis邊界

enter image description here

ax.get_ylim = (30, 90)。當我運行以下代碼:

ax.plot_date(dates_to_plot, y_obs2) 
foo = ax.get_ylim() 
ax.fill_between(dates_to_plot, foo[0], y_obs2) 

填充介於y_obs2(藍色凍結行)和30之間 - 這是預期的。我要的是y_obs2和20之間,以填補(或任何下邊界是當時的圖表)。

如果我只是普通的0,水平線下方的區域被完全填滿取代foo[0],但是這因爲圖表的下邊界變爲0,所以不是最優的。此外,y_obs1(溫度)可能變爲負值(不幸!)。我一直無法找到填充y_obs2行和圖表下邊界之間區域的方法 - 無論它是什麼。

是否有我沒有看到,可以提供圖表的邊界的元組的方法?

回答

0

您想要設置ylimits auto=False以確保在更改繪圖數據時不會重新計算它們。

ax.plot_date(dates_to_plot, y_obs2) 

# Get the current ylims 
foo = ax.get_ylim() 

# Prevent the axes ylims from changing automatically with new plots 
ax.set_ylim(auto=False) 

ax.fill_between(dates_to_plot, foo[0], y_obs2) 

# You can always manually specify the ylims as well 
# ax.set_ylim((lower, upper)) 
+0

感謝您的支持。這不是我想過的 - 設置與自己相同的東西 - 但它確實有效。非常感激。 – DaveL17

+0

@ DaveL17這是一種方式。我只是用更合乎邏輯的方式更新它 – Suever

+0

這確實說明了一些事情。這有效地賦予了我想要的任何東西的自由。乾杯。 – DaveL17