Thanks Tony, I think this will work!
Cheers,
Joe
On Mar 31, 2012, at 11:33 AM, Tony Yu wrote:
>
>
> On Fri, Mar 30, 2012 at 12:25 PM, eoj <josephmeir...@gmail.com> wrote:
>
> Basically the problem is like this. I have a relatively expensive (time wise)
> figure to create, specifically a map with lots of detail in it. On top of
> that, I'm making an inset set of axes to highlight some regions. I'm having
> to recreate the base of the map, which is static, every time I want to make
> an inset for a different region which is taking forever. What I want to do
> is something like this:
>
> fig = figure()
>
> #do stuff that makes the expensive figure
>
> for region in regions:
> fig2 = copy.copy(fig)
> ax2 = fig.add_axes([0.1, 0.15, 0.25, 0.25])
> ax2.fill(x1,y1)
> savefig(region_name)
> close()
>
>
>
> The problem is that the clf() clear figure function seems to clear the base
> of the map off, even if I try to make a copy of it inside a loop that is
> generating the insets. Also, close() seems to close fig and not fig2. Does
> this rambling make any sense, and if so, any suggestions?
>
>
> If all your additions are confined to the inset axes, you can use
> `fig.delaxes` to remove the axes from the figure (see example below). If you
> want to save and restore, as you describe above, you should (in principal) be
> able to do so with `canvas.copy_from_bbox` and `canvas.restore_region`, but I
> couldn't get it to work (see bottom of the animation cookbook).
>
> Cheers,
> -Tony
>
> # ~~~ example
> import numpy as np
> import matplotlib.pyplot as plt
>
> fig, ax = plt.subplots()
> ax.imshow(np.random.uniform(size=(10, 10)))
>
> ax_inset = fig.add_axes([0.3, 0.3, 0.2, 0.2])
> ax_inset.plot([0, 1])
> plt.savefig('plot0')
>
> fig.delaxes(ax_inset)
> ax_inset = fig.add_axes([0.5, 0.5, 0.2, 0.2])
> ax_inset.plot([1, 0])
> plt.savefig('plot1')
> # ~~~
>
=======================
Joseph D. Meiring
Department of Astronomy
LGRT 517
University of Massachusetts
Amherst MA 01003
=======================
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users