Toggle plot trace

Hello,

I'm working on a GUI with wxPython to display several traces of data.
Using a checkbox, I would like to be able to turn traces on the plot on
and off. I have managed to find the right methods to turn the whole
axes on and off, but not individual traces. Any help would be appreciated.

Thanks,
Dave
- –
David D. Clark
Electrical Engineer
P-23, Neutron Science and Technology
e-mail mailto:ddclark@…652…
GPG Public key 0x018D6523 available at http://www.us.pgp.net
http://www.gnupg.org has information about public key cryptography

Everythong that draws into a figure (Axes, Text, Line2D, Polygon,
etc...) all derive from Artist which has a visible property. So you
can turn anything off/on with

o.set_visible(True|False)

JDH

···

On 2/14/07, David Clark (Lists) <ddclark@...652...> wrote:

I'm working on a GUI with wxPython to display several traces of data.
Using a checkbox, I would like to be able to turn traces on the plot on
and off. I have managed to find the right methods to turn the whole
axes on and off, but not individual traces. Any help would be appreciated.

John Hunter wrote:

I'm working on a GUI with wxPython to display several traces of data.
Using a checkbox, I would like to be able to turn traces on the plot on
and off. I have managed to find the right methods to turn the whole
axes on and off, but not individual traces. Any help would be
appreciated.

Everythong that draws into a figure (Axes, Text, Line2D, Polygon,
etc...) all derive from Artist which has a visible property. So you
can turn anything off/on with

o.set_visible(True|False)

JDH

John,

Thanks for the reply. I thought it might have to do with that. I am a
new python/matplotlib user. In my inexperience, I'm not sure what I
should use for "o" in o.set_visible

Thanks,
Dave
- --
David D. Clark
Electrical Engineer
P-23, Neutron Science and Technology
ph. 505.667.4147 fx. 505.665.4121 pg. 505.996.1416
e-mail mailto:ddclark@…652…
GPG Public key 0x018D6523 available at http://www.us.pgp.net
http://www.gnupg.org has information about public key cryptography

···

On 2/14/07, David Clark (Lists) <ddclark@...652...> wrote:

o in the example above is any matplotlib artist, eg a line (returned
by plot), a text instance (returned by set_xlabel, set_ylabel,
set_title), a rectangle (returned by bar), etc.. Perhaps the example
below will clarify

In [1]: fig = figure()

In [2]: ax = fig.add_subplot(111)

In [3]: line, = ax.plot([1,2,3])

In [4]: xl = ax.set_xlabel('time')

In [5]: yl = ax.set_ylabel('volts')

In [7]: bars = ax.bar([1,2,3], rand(3))

In [8]: xl
Out[8]: <matplotlib.text.Text instance at 0x3c37238>

In [9]: yl
Out[9]: <matplotlib.text.Text instance at 0x3c37df0>

In [10]: line
Out[10]: <matplotlib.lines.Line2D instance at 0x3c3e558>

In [11]: bars
Out[11]:
[<matplotlib.patches.Rectangle instance at 0x6c92bc0>,
<matplotlib.patches.Rectangle instance at 0x6c92be8>,
<matplotlib.patches.Rectangle instance at 0x6c92c60>]

In [12]: xl.set_visible(False)

In [13]: draw()

In [14]: bars[1].set_visible(False)

In [15]: draw()

···

On 2/15/07, David D Clark <ddclark@...652...> wrote:

Thanks for the reply. I thought it might have to do with that. I am a
new python/matplotlib user. In my inexperience, I'm not sure what I
should use for "o" in o.set_visible

John Hunter wrote:

Thanks for the reply. I thought it might have to do with that. I am a
new python/matplotlib user. In my inexperience, I'm not sure what I
should use for "o" in o.set_visible

o in the example above is any matplotlib artist, eg a line (returned
by plot), a text instance (returned by set_xlabel, set_ylabel,
set_title), a rectangle (returned by bar), etc.. Perhaps the example
below will clarify

Example Removed

John,

That did the trick! I'm in business!

Dave

- --
David D. Clark
Electrical Engineer
P-23, Neutron Science and Technology
ph. 505.667.4147 fx. 505.665.4121 pg. 505.996.1416
e-mail mailto:ddclark@…652…
GPG Public key 0x018D6523 available at http://www.us.pgp.net
http://www.gnupg.org has information about public key cryptography

···

On 2/15/07, David D Clark <ddclark@...652...> wrote: