title: Make plt.colorbar extend to the steps immediately before and after vmin/vmax
body: <p>I want to do something with <code>plt.hist2d</code> and <code>plt.colorbar</code> and I'm having real trouble working out how to do it. To explain, I've written the following example:</p>
  
  <pre><code>import numpy as np
  from matplotlib import pyplot as plt
  
  x = np.random.random(1e6)
  y = np.random.random(1e6)
  
  plt.hist2d(x, y)
  plt.colorbar()
  
  plt.show()
  </code></pre>
  
  <p>This code generates a plot that looks something like the image below.
  <a href="https://i.stack.imgur.com/DNs79.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DNs79.png" alt="2D histogram with colorbar plotted using pyplot"></a></p>
  
  <p>If I generate a histogram, ideally I would like the colour bar to extend beyond the maximum and minimum range of the data to the next step beyond the maximum and minimum. In the example in this question, this would set the colour bar extent from 9660 to 10260 in increments of 60.</p>
  
  <p>How can I force either <code>plt.hist2d</code> or <code>plt.colorbar</code> to set the colour bar such that ticks are assigned to the start and end of the plotted colour bar?</p>