Hi,

I would like to plot a colorbar which automatically gets resized when  
I change the view limits and the aspect ratio of the main axes. So for  
example:

import matplotlib.pyplot as mpl
import numpy as np

fig = mpl.figure()
ax = fig.add_axes([0.1,0.1,0.7,0.8])
cax = fig.add_axes([0.81,0.1,0.02,0.8])

image = ax.imshow(np.random.random((100,100)))

fig.colorbar(image, cax=cax)

Is fine, but then if I interactively select a sub-region to zoom in  
with a different aspect ratio, which I can also emulate by doing

ax.set_ylim(40.,60.)

The colorbar is then too high. If I then do

ax.set_xlim(50.,55.)

The height is fine but the position would need changing.

Is there an easy way to get around this issue and have the colorbar  
always at a fixed distance from the main axes, and also have it  
resize? Or is the only way to write this all explicitly using event  
callbacks?

Thanks for any help,

Thomas

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to