![](/img/trans.png)
[英]Python Matplotlib (1) format x-axis labels to Year-Quarter and (2) set major_locator to end of month
[英]Matplotlib: putting together figure, xaxis, minor_locator, major_locator
我正在嘗試繪制一個非常基本的圖,將幾個參數放在一起。 這就是我走了多遠。 不幸的是,文檔及其示例並未涵蓋我的問題:
fig=plt.figure(figsize=(50,18), dpi=60)
dax_timeseries_xts.plot(color="blue", linewidth=1.0, linestyle="-", label='DAX')
# dax_timeseries_xts is a XTS with dates as index
ax.xaxis.set_minor_locator(dates.WeekdayLocator(byweekday=(1),interval=1))
ax.xaxis.set_minor_formatter(dates.DateFormatter('%d\n%a'))
ax.xaxis.grid(True, which="minor")
ax.yaxis.grid()
ax.xaxis.set_major_locator(dates.MonthLocator())
ax.xaxis.set_major_formatter(dates.DateFormatter('\n\n\n%b\n%Y'))
plt.tight_layout()
plt.show()
為了使這項工作有效,我在哪里創建“ ax”? 也許我沒有有效地將上面列出的參數組合在一起來創建圖表?
fig, ax_f = plt.subplots(nrows=1, ncols=1)
會給你軸
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.