title: Adding a colorbar outside an image without shrinking it
body: <p>I'm trying to plot a 3x3 subplots, the first line using imshow, and second and third are regular graphs. All the 3x3 plots share the same x-axis, so it's really important that they will be perfectly aligned (I didn't use sharey=true because I wanted the y-ticks). I was able to put the graphs legends outside the figure in the right (the legend is the same legend for the whole 3 figures in the same row) by using:</p>
  
  <pre><code>ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
  </code></pre>
  
  <p>But I couldn't find how to put the colorbar of the first row above them, without shrinking the third plot in the first row. I was trying to use "make_axes_locatable":</p>
  
  <pre><code>from mpl_toolkits.axes_grid1 import make_axes_locatable
  divider = make_axes_locatable(powers_ax)
  cax = divider.append_axes("right", size="5%", pad=1)
  plt.colorbar(im, cax=cax)
  </code></pre>
  
  <p>Or "inset_axes":</p>
  
  <pre><code>from mpl_toolkits.axes_grid1.inset_locator import inset_axes
  axins = inset_axes(powers_ax, width="10%", height="100%", loc=5,
                     bbox_to_anchor=(0.5, 0, 1, 1), bbox_transform=powers_ax.transAxes)
  plt.colorbar(im, cax=axins)
  </code></pre>
  
  <p>Or even this trick:</p>
  
  <pre><code>fig.colorbar(im2, ax=ax[0, :].ravel().tolist(), location='right', shrink=0.6)
  </code></pre>
  
  <p>But nothing gave me the result I watned.
  Any ideas?</p>
  
  <p><strong>* EDIT *</strong></p>
  
  <p>As @ImportanceOfBeingErnest suggested, the solution was tweaking the first parameter in the bbox_to_anchor (from 0.5 to 1.15 in this case):</p>
  
  <pre><code>from mpl_toolkits.axes_grid1.inset_locator import inset_axes
  axins = inset_axes(powers_ax, width="5%", height="100%", loc=5,
                     bbox_to_anchor=(1.15, 0, 1, 1), bbox_transform=powers_ax.transAxes)
  plt.colorbar(im2, cax=axins)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/zYjfN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zYjfN.png" alt="enter image description here"></a></p>