Hiding line plots

Hi,

Is there a way I can hide a line plot? I have several line plots, and I want to make a function to enable or disable a plot… How do I tell each line apart and remove/reinsert them?

Anyone tried this? I was seeking for a line ID of somekind in matplotlib.lines… but didn’t see any.

Thanks,
Soren

When you create the plot, it returns a list of line objects. You can use this object to remove itself from the axes, and add it back it later. Hope this helps::

In [1]: l1 = plot([1,2,3])

In [2]: l2 = plot([4,5,6])

In [4]: l1
Out[4]: [<matplotlib.lines.Line2D object at 0xb676124c>]

# Remove the first plot
In [6]: l1[0].remove()

# Put it back
In [9]: axes().add_line(l1[0])

Cheers,
Mike

S�ren Nielsen wrote:

···

Hi,

Is there a way I can hide a line plot? I have several line plots, and I want to make a function to enable or disable a plot.. How do I tell each line apart and remove/reinsert them?

Anyone tried this? I was seeking for a line ID of somekind in matplotlib.lines... but didn't see any.

Thanks,
Soren
------------------------------------------------------------------------

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

S�ren Nielsen wrote:

Is there a way I can hide a line plot? I have several line plots, and I want to make a function to enable or disable a plot.. How do I tell each line apart and remove/reinsert them?

Try this in an interactive session, and see if it helps:

ax = figure().add_subplot(111)
a = ax.plot(rand(10), 'k')[0]
b = ax.plot(rand(10), 'r')[0]
ax.figure.canvas.draw()
a.set_visible(False)
ax.figure.canvas.draw()

Regards,
Antonio