Hi,
I am trying to set up a colorbar that automatically resizes if I zoom in to an
image (which changes the aspect ratio of the axes, so I want the colorbar to
get resized too). Let's say I have two Axes instances, say ax (for the main
image) and cax (for the colorbar). I can set up a callback if the view limits
in one axes change, for example
ax.callbacks.connect('xlim_changed', update_colorbar)
ax.callbacks.connect('ylim_changed', update_colorbar)
Now I can store a reference to cax inside ax:
ax._cax = cax
And I can now define update_colorbar so that it basically changes the position
of cax:
def update_colorbar(ax):
# Get current position
xmin = ax..get_position().xmin
...
# Compute new colorbar position
...
# Set new position
ax._cax.set_position(...)
# Return axes instance
return ax
Now the issue is that if I select a region of the image to zoom into, then as
soon as I've selected the region, update_colorbar gets called, but by then, the
aspect ratio of ax hasn't changed, and so the position I find when I do xmin =
ax..get_position().xmin in update_colorbar is the *old* position of ax, not the
new one. So the colorbar position is always one step behind compared to the
main image axes.
Can anyone think of any way that would avoid this issue, and to be able to use
the *new* position of ax inside update_colorbar?
Thanks in advance for any help,
Thomas
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users