Removing a line from a plot

Hi NG,

    I posted this question few months ago and I didn't receive any
answer, so I'll try to rephrase my problem.

I have a GUI written in wxPython, the main portion of it is a
matplotlib canvas. There is a tree control on the left with
checkboxes: if the user checks a checkbox, I add a line on the plot.
So far so good. The problem comes when the user *un-checks* the
checkbox. I would like to remove the line from the plot, but the only
way I found to do it is to do:

line.set_linestyle("None")

Which is not very nice (and not very correct), as it seems to me that
the line is still there (invisible, but still there). Am I right or
have I completely misunderstood the set_linestyle behavior? If this
method is not correct, is there any alternative that I could try to
erase completely the line from the plot (and from the legend,
obviously)?
The alternative of replotting everything just because a line should be
erased came into my mind but I discarded it because it is
fantastically time consuming with my graphs.

Thank you for every hint.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

I have a GUI written in wxPython, the main portion of it is a
matplotlib canvas. There is a tree control on the left with
checkboxes: if the user checks a checkbox, I add a line on the plot.
So far so good. The problem comes when the user *un-checks* the
checkbox. I would like to remove the line from the plot, but the only
way I found to do it is to do:

To suppress the last line drawn:
del(gca().lines[-1])

(replace gca() by the handle of the subplot you're acting on)

Thank you guys, and thanks for the Wiki entry :wink:

Andrea.

···

On 11/9/06, Pierre GM <pgmdevlist@...287...> wrote:

> I have a GUI written in wxPython, the main portion of it is a
> matplotlib canvas. There is a tree control on the left with
> checkboxes: if the user checks a checkbox, I add a line on the plot.
> So far so good. The problem comes when the user *un-checks* the
> checkbox. I would like to remove the line from the plot, but the only
> way I found to do it is to do:

To suppress the last line drawn:
del(gca().lines[-1])

(replace gca() by the handle of the subplot you're acting on)

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/