title: How to change xticks to yearly interval in pandas time series plot
body: <p>I am very new to pandas, and I have searched many StackOverflow questions similar to this for changing xtick labels yearly, but they all are different did not solve my problem, so I decided to ask my own question.</p>
  
  <p>Here is my question. I have a mock data frame which I want to plot yearly xticks in the x-axis.</p>
  
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  import pandas as pd
  
  df = pd.DataFrame({'date': pd.date_range('1991-01-01','2019-01-01')}).set_index('date')
  df['value'] = np.random.randn(len(df))
  df.plot()
  
  </code></pre>
  
  <p>This gives:
  Xticks ==> 1995 2000 2005 etc
  But I want ==> 1991 1992 ... 2019</p>
  
  <p>How to do that?</p>
  
  <p>So far I have tried this:</p>
  
  <pre class="lang-py prettyprint-override"><code>import matplotlib
  import matplotlib
  import matplotlib.pyplot as plt
  
  %matplotlib inline
  
  fig,ax = plt.subplots()
  df.plot(ax=ax)
  
  ax.xaxis.set_major_locator(matplotlib.dates.YearLocator(base=1))
  # ax.xaxis.set_minor_locator(matplotlib.dates.YearLocator(base=1))
  
  # ax.set_xticklabels(list(df.index.time))
  
  </code></pre>
  
  <p>This gives just 2005 as xtick and nothing has worked till now.</p>
  
  <p>Links I looked:
  - <a href="https://stackoverflow.com/questions/49522899/changing-xticks-in-a-pandas-plot">Changing xticks in a pandas plot</a>
  - <a href="https://stackoverflow.com/questions/28307607/python-change-the-time-on-xticks-for-pandas-plot">Python: Change the time on xticks for Pandas Plot</a>
  - <a href="https://matplotlib.org/3.1.1/api/dates_api.html" rel="nofollow noreferrer">https://matplotlib.org/3.1.1/api/dates_api.html</a></p>