title: How to set two time formatters in matplotlib?
body: <p>This chart is built by Excel.
  <a href="https://i.stack.imgur.com/bEvbW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bEvbW.png" alt="enter image description here" /></a>
  How can I do the same using matplotlib?</p>
  <p>I mean how to add two formatters:</p>
  <ul>
  <li>years</li>
  <li>months.</li>
  </ul>
  <p>Now i use something like this:</p>
  <pre><code>fig, ax = plt.subplots(1,1)
  ax.margins(x=0)
  ax.plot(list(df['Date']), list(df['Value']), color=&quot;g&quot;)
  ax.xaxis.set_major_locator(matplotlib.dates.YearLocator())
  ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Y'))
  plt.text(df[&quot;Date&quot;].iloc[-1], df[&quot;Value&quot;].iloc[-1], df[&quot;Value&quot;].iloc[-1])
  plt.title(title)
  plt.get_current_fig_manager().full_screen_toggle()
  plt.grid(axis = 'y')
  plt.savefig('pict\\'+sheet.cell_value(row,1).split(',')[0]+'.png', dpi=300, format='png')
  #plt.show()
  plt.close(fig)
  </code></pre>
  <p>It draws:</p>
  <p><a href="https://i.stack.imgur.com/g0fFT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g0fFT.png" alt="enter image description here" /></a></p>