title: matplotlib: change the current axis instance (i.e., gca())
body: <p>I use a trick to <a href="http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#colorbar-whose-height-or-width-in-sync-with-the-master-axes">draw a colorbar whose height matches the master axes</a>. The code is like</p>
  
  <pre><code>import matplotlib.pyplot as plt
  from mpl_toolkits.axes_grid1 import make_axes_locatable
  import numpy as np
  
  ax = plt.subplot(111)
  im = ax.imshow(np.arange(100).reshape((10,10)))
  
  # create an axes on the right side of ax. The width of cax will be 5%
  # of ax and the padding between cax and ax will be fixed at 0.05 inch.
  divider = make_axes_locatable(ax)
  cax = divider.append_axes("right", size="5%", pad=0.05)
  
  plt.colorbar(im, cax=cax)
  </code></pre>
  
  <p>This trick works good. However, since a new axis is appended, the current instance of the figure becomes cax - the appended axis. As a result, if one performs operations like</p>
  
  <pre><code>plt.text(0,0,'whatever')
  </code></pre>
  
  <p>the text will be drawn on cax instead of ax - the axis to which im belongs.</p>
  
  <p>Meanwhile, gcf().axes shows both axes.</p>
  
  <p>My question is: How to make the current axis instance (returned by gca()) the original axis to which im belongs.</p>