title: Python: year or month on x axis with pyplot, pandas and matplotlib?
body: <p>There are plethora of different solutions, mostly outdated, to address the addition of axis in matplotlib object, haven't got any of them working yet. I want to get date labels (either Months or Years) on the x axis.</p>
  
  <h2><strong>How to add the date annotations on the axis in Python with Pandas and Matplotlib?</strong></h2>
  
  <p><strong>MWE</strong></p>
  
  <pre><code>import pandas as pd
  from matplotlib.pyplot import savefig
  
  a=pd.read_csv("test.csv")
  a.pivot(index='date', columns='group').plot()
  savefig("plot3.png")
  </code></pre>
  
  <p><strong>test.csv</strong></p>
  
  <pre><code>date,group,myval
  2018-07-01,test1,999
  2018-07-01,test2,523
  2018-07-02,test1,3305
  2018-07-02,test2,1290
  2018-07-03,test1,9399
  2018-07-03,test2,1827
  2018-07-04,test1,6982
  2018-07-04,test2,2391
  2018-07-05,test1,4100
  2018-07-05,test2,2081
  2018-07-06,test1,0268
  2018-07-06,test2,4834
  2018-07-07,test1,9571
  2018-07-07,test2,6369
  2018-07-08,test1,3943
  2018-07-08,test2,6483
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rH1Ek.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rH1Ek.png" alt="enter image description here"></a></p>
  
  <p>where the time annotations are missing.</p>