title: Date formatting for bar charts in matplotlib
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3486121/how-to-plot-data-against-specific-dates-on-the-x-axis-using-matplotlib">How to plot data against specific dates on the x-axis using matplotlib</a><br>
    <a href="https://stackoverflow.com/questions/6974847/plot-with-non-numerical-data-on-x-axis-for-ex-dates">Plot with non-numerical data on x axis (for ex., dates)</a>  </p>
  </blockquote>
  
  
  
  <p>I am attempting to generate a bar graph in matplotlib where the x-axis and y-axis values are tuples of (dates, integers). The data has the following form:</p>
  
  <pre><code>data = [('2012-02-26', 17), ('2012-03-07', 16), ('2012-06-30', 16), 
          ('2012-03-16', 15), ('2012-06-24', 15), ('2012-05-13', 14), 
          ('2012-03-19', 12), ('2012-02-18', 9), ('2012-04-07', 9), 
          ('2012-04-09', 8)]
  </code></pre>
  
  <p>I can generate a simple bar graph if I simply use integers as x values:</p>
  
  <pre><code>import scipy as sp
  from matplotlib import pyplot as pl
  x = sp.arange(100)
  y = sp.random.randint(1,100, 100)
  fig = figure()
  pl.bar(x,y)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/mA8iC.png" alt="enter image description here"></p>
  
  <p>How can I plot a similar bar graph with string dates on the x-axis? Ideally, I would also like to have the x-axis labels show as dates. I found a similar example on the <a href="http://matplotlib.sourceforge.net/users/recipes.html" rel="nofollow noreferrer">matplotlib recipe page</a>, but I could not get it to work with my example. Thanks for the help.</p>