2016-12-30 53 views
-1

我密謀與matplotlib一個timeserie(timeserie如下所示): enter image description here蟒蛇matplotlib - 檢索xaxis_major_locator隨着時間的價值

,我使用套主要定位爲在每天0AM部分代碼:

fig, ax = plt.subplots(figsize=(20, 3)) 
mpf.candlestick_ohlc(ax,quotes, width=0.01) 
ax.xaxis_date() 
ax.xaxis.set_major_locator(mpl.dates.DayLocator(interval=1)) 

我想在圖表上爲每天下午16點和上午8點繪製較暗的背景,並且計劃使用axvspan來執行該任務。考慮到axvspan把參數作爲axvspan(xmin, xmax)我想知道是否有可能爲了將它傳遞給axvspan爲axvspan(xmin=major_locator-3600s, xmax=major_locator+3600s)

編輯檢索xaxis_major_locator斧值:我發現在文檔中該功能:http://matplotlib.org/2.0.0rc2/api/ticker_api.html#matplotlib.ticker.Locator

如果有人知道如何從Xaxis_major返回一個股票代碼位置的列表,它讓我知道。謝謝。

編輯2:如果我使用print(ax.xaxis.get_major_locator())作爲回報我收到<matplotlib.dates.DayLocator object at 0x7f70f3b34090>如何從該表中刪除勾號位置列表?

回答

0

好的發現它... majors = ax.xaxis.get_majorticklocs()