title: Position colorbar inside figure
body: <p>I have a simple scatter plot where each point has a color given by a value between 0 and 1 set to a chosen colormap. Here's a <code>MWE</code> of my code:</p>
  
  <pre><code>import matplotlib.pyplot as plt 
  import numpy as np
  import matplotlib.gridspec as gridspec
  
  x = np.random.randn(60) 
  y = np.random.randn(60)
  z = [np.random.random() for _ in range(60)]
  
  fig = plt.figure()
  gs = gridspec.GridSpec(1, 2)
  
  ax0 = plt.subplot(gs[0, 0])
  plt.scatter(x, y, s=20)
  
  ax1 = plt.subplot(gs[0, 1])
  cm = plt.cm.get_cmap('RdYlBu_r')
  plt.scatter(x, y, s=20 ,c=z, cmap=cm)
  cbaxes = fig.add_axes([0.6, 0.12, 0.1, 0.02]) 
  plt.colorbar(cax=cbaxes, ticks=[0.,1], orientation='horizontal')
  
  fig.tight_layout()
  plt.show()
  </code></pre>
  
  <p>which looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/wYKWm.png" alt="pic"></p>
  
  <p>The problem here is that I want the small horizontal colorbar position to the lower left of the plot but using the <code>cax</code> argument not only feels a bit hacky, it apparently conflicts with <code>tight_layout</code> which results in the warning: </p>
  
  <pre><code>/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py:1533: UserWarning: This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect.
    warnings.warn("This figure includes Axes that are not "
  </code></pre>
  
  <p>Isn't there a better way to position the colorbar, ie without getting a nasty warning thrown at you whenever you run the code?</p>
  
  <hr>
  
  <h2>Edit</h2>
  
  <p>I wanted the colorbar to show only the max and min values, ie: 0 and 1 and Joe helped me do that by adding <code>vmin=0, vmax=1</code> to <code>scatter</code> like so:</p>
  
  <pre><code>plt.scatter(x, y, s=20, vmin=0, vmax=1)
  </code></pre>
  
  <p>so I'm removing this part of the question.</p>