How to set two time formatters in matplotlib?
问题 This chart is built by Excel. How can I do the same using matplotlib? I mean how to add two formatters: years months. Now i use something like this: fig, ax = plt.subplots(1,1) ax.margins(x=0) ax.plot(list(df['Date']), list(df['Value']), color="g") ax.xaxis.set_major_locator(matplotlib.dates.YearLocator()) ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Y')) plt.text(df["Date"].iloc[-1], df["Value"].iloc[-1], df["Value"].iloc[-1]) plt.title(title) plt.get_current_fig_manager()