title: Matplotlib: How to fix unexpected x tick behaviour
body: <p>I'm making matplotlib lineplots and the x ticks are behaving so counterintuitively. </p>
  
  <p>Here is my dataframe:</p>
  
  <pre><code>    year        x       y
  0   2012        8154    13496
  1   2013        8585    11421
  2   2014        10376   10890
  3   2015        11720   10714
  </code></pre>
  
  <p>This code:</p>
  
  <pre><code>f, ax1 = plt.subplots(1, figsize=(12, 7))
  
  ax1.plot(WholeGrouped['x'],
           marker='o',
           lw=1,
           markersize=9,
           linestyle = '--',
           color='#666666')
  
  ax1.plot(WholeGrouped['y'],
           marker='o',
           lw=3,
           markersize=10,
           color='#12A4DD')
  
  labels = [2012, 2013, 2014, 2015]
  
  ax1.set_xticklabels(labels)
  </code></pre>
  
  <p>Produces this:</p>
  
  <p><a href="https://i.stack.imgur.com/11Bxj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/11Bxj.png" alt="enter image description here"></a></p>
  
  <p>Clearly though I want the year labels to be positioned relative to the markers. How do I assign the labels to the correct position?</p>
  
  <p>The genesis of the problem is that Matplotlib returned something totally bizarre when I tried to use the years as the x axis. As follows:</p>
  
  <pre><code>f, ax1 = plt.subplots(1, figsize=(12, 7))
  
  ax1.plot(WholeGrouped['x'],
           marker='o',
           lw=1,
           markersize=9,
           linestyle = '--',
           color='#666666')
  
  ax1.plot(WholeGrouped['y'],
           WholeGrouped['year'],
           marker='o',
           lw=3,
           markersize=10,
           color='#12A4DD')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/FrDxL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FrDxL.png" alt="enter image description here"></a></p>
  
  <p>Hence I went down the labels route.</p>
  
  <p>How hard can it be to make the x axis the years and have them properly spaced out!</p>