moving around artists form one axes to the other can be very tricky
due to the underlying design of mpl. So, it is generally better idea
to create artists for each axes, instead of reusing them.

For a simple case as yours, adding the following line after
line.remove() will work.

line._transformSet = False

Regards,

-JJ


On Mon, Oct 5, 2009 at 12:37 PM, TP <paratribulati...@free.fr> wrote:
> Hi everybody,
>
> I try to move an instance of matplotlib.lines.Line2D from one subplot to
> another. How to do that? I have tried the following code, but the Line2D
> does not appear on the second subplot.
>
> Thanks in advance,
>
> Julien
>
> ###############
> from pylab import *
>
> ion()
> f = figure()
> s = f.add_subplot("211")
> line = matplotlib.lines.Line2D([0,1],[0,1],color='m')
> s.add_line( line )
> s2 = f.add_subplot("212")
>
> draw()
>
> raw_input( 'press a key to remove the line and try to add it to second
> subplot' )
>
> line.remove()
> s2.add_line( line )
> draw()
>
> raw_input('press a key to quit')
> #####################
>
> --
> python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\
> 9&1+,\'Z4(55l4('])"
>
> "When a distinguished but elderly scientist states that something is
> possible, he is almost certainly right. When he states that something is
> impossible, he is very probably wrong." (first law of AC Clarke)
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to