removing lines from plot

redlines.set_visible(False)

it is also possible to delete the line from ax.lines.
Ex: del ax.lines[-1] deletes the last line.

you need to perform a redraw for the change to be visible on the plot.

Hi I've added some lines with ax.add_line(yellowlines) ax.add_line(redlines)

how can I remove the lines without completely redrawing everything?

-Mathew

There are more “correct” ways to do this. For example, each artist object comes with a “remove” method:

http://matplotlib.sourceforge.net/api/artist_api.html?highlight=remove#matplotlib.artist.Artist.remove

So, if you save the lines that you create from the call to plot, you can subsequently remove them at your leisure.

Ben Root

···

On Wed, May 4, 2011 at 11:23 PM, <butterw@…287…> wrote:

redlines.set_visible(False)

it is also possible to delete the line from ax.lines.
Ex: del ax.lines[-1] deletes the last line.

you need to perform a redraw for the change to be visible on the plot.