title: Matplotlib: Different colors for each date, labelled via colorbar
body: <p>I have a system in two variables, <code>v</code> and <code>u</code>, which change over time. I would like to plot them against each other, and have the time indicated by the color.</p>
  
  <p>Here is my data, where the index was generated using <code>pd.to_datetime()</code>:</p>
  
  <pre><code>              v          u
  date                      
  2001-01-01  3.9   4.290910
  2002-01-01  2.8   5.807681
  2003-01-01  2.8   5.956179
  2004-01-01  2.6   5.771250
  2005-01-01  2.7   5.335874
  2006-01-01  3.1   4.792693
  2007-01-01  3.3   4.576049
  2008-01-01  3.0   5.008100
  2009-01-01  2.0   8.392731
  2010-01-01  2.0   9.961898
  2011-01-01  2.2   9.168686
  2012-01-01  2.7   8.360966
  2013-01-01  2.7   7.805654
  2014-01-01  2.7   6.742811
  2001-04-01  3.6   4.474629
  2002-04-01  2.6   5.899864
  2003-04-01  2.5   6.209195
  2004-04-01  2.7   5.644648
  2005-04-01  3.1   5.170083
  </code></pre>
  
  <p>I tried</p>
  
  <pre><code>fig, ax = plt.subplots()
  smap = ax.scatter(df['v'],df['u'],s=500,c=df.index,
                    edgecolors='none', marker='o', cmap=cmap) )
  
  cb = fig.colorbar(smap, orientation='vertical')
  
  cb.ax.set_yticklabels(df.index.strftime('%b %Y'))
  </code></pre>
  
  <p>However, it falsely now sets the date range from 2001-2003, instead of 2001-2014:</p>
  
  <p><a href="https://i.stack.imgur.com/9B4uO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9B4uO.png" alt="smaple image"></a></p>