title: Plotting dates with matplotlib
body: <p>I've been attempting to plot data from a comma delimited csv file which contains a date and a float:</p>
  
  <pre><code>Date,Price (€)
  01062017,20.90
  02062017,30.90
  03062017,40.90
  04062017,60.90
  05062017,50.90
  </code></pre>
  
  <p>I then attempt to plot this with the following code:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  import datetime
  
  dates,cost = np.loadtxt('price_check.csv',delimiter=',',skiprows=1,unpack=True)
  
  xdates = [datetime.datetime.strptime(str(int(date)),'%d%m%Y') for date in dates]
  
  fig = plt.figure()
  ax = plt.subplot(111)
  plt.plot(xdates, cost,'o-',label='Cost')
  plt.legend(loc=4)
  plt.ylabel('Price (Euro)')
  plt.xlabel('date')
  plt.gcf().autofmt_xdate()
  plt.grid()
  plt.savefig('sunglasses_cost.png')
  plt.show()
  </code></pre>
  
  <p>However, when the data is plotted, it looks like the leading zero in in the date string is being dropped:</p>
  
  <p><a href="https://i.stack.imgur.com/XiQaR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XiQaR.png" alt="enter image description here"></a></p>
  
  <p>Is there an easy way for the full date to be used in the plot?</p>