title: Set Colorbar range with "contourf" in matplotlib
body: <p>How to reduce the colorbar limit when used with contourf ? The color bound from the graphs itself are well set with "vmin" and "vmax", but the colorbar bounds are not modified.</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  x = np.arange(20)
  y = np.arange(20)
  data = x[:,None]+y[None,:]
  
  X,Y = np.meshgrid(x,y)
  vmin = 0
  vmax = 15
  
  #My attempt
  fig,ax = plt.subplots()
  contourf_ = ax.contourf(X,Y,data, 400, vmin=vmin, vmax=vmax)
  cbar = fig.colorbar(contourf_)
  cbar.set_clim( vmin, vmax )
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/2Ivtb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2Ivtb.png" alt="enter image description here"></a></p>
  
  <pre><code># With solution from https://stackoverflow.com/questions/53641644/set-colorbar-range-with-contourf
  levels = np.linspace(vmin, vmax, 400+1)
  fig,ax = plt.subplots()
  contourf_ = ax.contourf(X,Y,data, levels=levels, vmin=vmin, vmax=vmax)
  cbar = fig.colorbar(contourf_)
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Xw32D.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Xw32D.png" alt="enter image description here"></a></p>
  
  <p>solution from "<a href="https://stackoverflow.com/questions/3373256/set-colorbar-range-in-matplotlib">Set Colorbar Range in matplotlib</a>" works for pcolormesh, but not for contourf. The result I want looks like the following, but using contourf.</p>
  
  <pre><code>fig,ax = plt.subplots()
  contourf_ = ax.pcolormesh(X,Y,data[1:,1:], vmin=vmin, vmax=vmax)
  cbar = fig.colorbar(contourf_)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/EMTMQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EMTMQ.png" alt="enter image description here"></a></p>
  
  <p>Solution from "<a href="https://stackoverflow.com/questions/53641644/set-colorbar-range-with-contourf">set colorbar range with contourf</a>" would be ok if the limit were extended, but not if they are reduced.</p>
  
  <p>I am using matplotlib 3.0.2</p>