title: Matplotlib x-ticks goes from Jan-Jan instead of Jan-Dec
body: <p>I have daily weather data from Jan 1 - Dec 31 for a year. I'm plotting this daily data and want my x-ticks to be monthly intervals. But when I plot it, the x-tick goes from Jan - Jan instead of Jan-Dec. How do I get rid of the last x-tick that has Jan and limit it till December. </p>
  
  <p>If I set the xlim from Jan to Dec the graph covers the entire axes. I want a bit of a gap from where the lines start and ends. </p>
  
  <p>Date is in the format YYYY-MM-DD</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import matplotlib.dates as mdates
  import datetime
  
  plt.figure()
  plt.plot(minmax2014['Date'], minmax2014['min'], color='r', label='Record High')
  plt.plot(minmax2014['Date'], minmax2014['max'], color='b', label='Record Low')
  
  plt.legend(loc=2)
  
  d=minmax2014['Date'].values
  plt.gca().fill_between(d, minmax2014['max'], minmax2014['min'], facecolor='yellow', alpha=0.3)
  
  plt.gca().xaxis.set_major_locator(mdates.MonthLocator())
  plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%b'))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/BKS0r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BKS0r.png" alt="the Graph with xticks"></a></p>