title: matplotlib centered bar chart with dates
body: <p>To get the bars where the x-axis are dates, I am doing something like this:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  import datetime
  
  x = [datetime.datetime(2010, 12, 1, 0, 0),
      datetime.datetime(2011, 1, 1, 0, 0),
      datetime.datetime(2011, 5, 1, 1, 0)]
  y = [4, 9, 2]
  
  ax = plt.subplot(111)
  barWidth=20
  ax.bar(x, y, width=barWidth)
  ax.xaxis_date()
  
  plt.show()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/dkb2J.png" alt="enter image description here"></p>
  
  <p>However, the plots are not centered around x. If have previously used ax.bar(x-barWidth/2.,y,width=barWidth) to get bar, which are centered around x. Is there a way to get the same when the x-axis values are dates?</p>