title: Put value at centre of bins for histogram
body: <p>I have the following code to plot a histogram.  The values in <code>time_new</code> are the hours when something occurred.</p>
  
  <pre><code>    time_new=[9, 23, 19, 9, 1, 2, 19, 5, 4, 20, 23, 10, 20, 5, 21, 17, 4, 13, 8, 13, 6, 19, 9, 14, 9, 10, 23, 19, 23, 20, 19, 6, 5, 24, 20, 19, 15, 14, 19, 14, 15, 21]
  
      hour_list = time_new
      print hour_list
      numbers=[x for x in xrange(0,24)]
      labels=map(lambda x: str(x), numbers)
      plt.xticks(numbers, labels)
      plt.xlim(0,24)
      pdb.set_trace()
      plt.hist(hour_list,bins=24)
      plt.show()
  </code></pre>
  
  <p>This produces a histogram, but the bins are not aligned as I would like.  I want the hour to be in the centre of the bin, not on the edge.</p>
  
  <p><a href="https://i.stack.imgur.com/Z06Al.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Z06Al.png" alt="Histogram of time_new with default bins"></a></p>
  
  <p>I referred to <a href="https://stackoverflow.com/questions/8369584/plot-histogram-of-datetime-time-python-matplotlib/8375556#comment52768522_8375556">this question / answer</a>, but it seems not to answer the question either.</p>
  
  <p>I tried the following code for the histogram plot instead, but it didn't plot a bar for the value <code>23</code></p>
  
  <pre><code>plt.hist(hour_list, bins=np.arange(24)-0.5)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/HhwBv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HhwBv.png" alt="histogram with bin range specified"></a></p>
  
  <p>Can anyone help me to get 24 bins, with the hour at the centre of each?</p>