title: Setting matplotlib colorbar range (larger range than the values plotted)
body: <p>I want to plot some data (between 0 and 18) but I want the colorbar to show a range between 0 and 40.
  After going through several online examples, I have no idea on how to achieve what I need!</p>
  
  <p>Here is a simple example:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  rd = np.random.rand(40,100) # random samples from a uniform distribution over [0, 1]
  surface = 18 * rd           # maximum value will be 18
  
  fig = plt.figure()
  ax = fig.add_subplot(111)
  cores = ax.contourf(surface[:], vmin=0, vmax=40)
  
  cbar = plt.colorbar(cores)
  </code></pre>
  
  <p>I've tried this as well:</p>
  
  <pre><code>cbar = plt.colorbar(cores, extend='both', extendrect=True)
  cbar.set_clim(0, 40.)
  </code></pre>
  
  <p>But I keep getting the same image, with a colorbar ranging from 0 to 20!
  I know I could use the <code>set_over</code> method, but I don't want to get a single color... I want my whole color range (as defined in <code>cores</code>, from 0 to 40) to appear!</p>
  
  <p><a href="https://i.stack.imgur.com/xAOSs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xAOSs.png" alt="enter image description here"></a></p>
  
  <p>Thanks for your help!</p>