简体   繁体   中英

Matplotlib: putting together figure, xaxis, minor_locator, major_locator

I am trying to plot a very basic plot putting several parameters together. This is how far I have come. Unfortunately the documentation and its examples does not cover my issue:

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()

Where do I create the "ax" in order to make this work? Or maybe I am not efficiently putting the arguments listed above together to create my chart?

fig, ax_f = plt.subplots(nrows=1, ncols=1)

会给你轴

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM