[SciPy-dev] PlotCanvas

eric jones ejones17 at austin.rr.com
Wed Oct 24 16:19:03 CDT 2001


Hey Jochen,

The figure() method is actually meant for doing this -- although I looked at
it and noticed the code was disabled.  I've enabled it and rewritten a
little in the current CVS.  figure() works very much like Matlab's figure.
figure() without arguments generates a new figure.  If a numerical index is
supplied, figure grabs the plot with that index (first plot created has
index 0).  If an actual plot frame is supplied, that plot is made the active
figure. So

    >>> a = plt.plot((1,2,3)) # generate a figure
    >>> figure()                    #generate new figure
    >>> figure(a)                  # activate first figure

Here figure(a) is equivalent to your setActive(a).

One more comment.  Please name functions and classes intended for scipy with
all lower-case/underscore convention (setActive() --> set_active().  This
has been used as uniformly as possible across the entire package (although
some things are still getting fixed).

thanks,
eric



More examples:

>>> import gui_thread
>>> <wxPython imported>
>>> from scipy import plt
>>> q=plt.plot((1,2,3))
>>> q.Raise()
>>> q
<C wxFrame instance at _e28688_wxFrame_p>
>>> plt.figure()
<C wxFrame instance at _e22c10_wxFrame_p>
>>> plt.plot((1,2,3))
<C wxFrame instance at _e22c10_wxFrame_p>
>>> plt.figure(0)
<C wxFrame instance at _e28688_wxFrame_p>
>>> plt.figure(1)
<C wxFrame instance at _e22c10_wxFrame_p>
>>> plt.figure(q)
<C wxFrame instance at _e28688_wxFrame_p>


----- Original Message -----
From: "Jochen Küpper" <jochen at unc.edu>
To: "scipy-dev" <scipy-dev at scipy.org>
Sent: Wednesday, October 24, 2001 11:13 AM
Subject: [SciPy-dev] PlotCanvas


> All,
>
> I have created a very q+d-hacked PlotCanvas based on scipy.plt. In
> case anybody is interested, the bare class file is attached. Feel free
> to add this to scipy.plt if you see it fit. It requires one patch to
> scipy.plt itself to access _active from the outside (q+d, as I said!):
>
> Index: plt/interface.py
> ===================================================================
> RCS file: /home/cvsroot/world/scipy/plt/interface.py,v
> retrieving revision 1.10
> diff -u -r1.10 interface.py
> --- plt/interface.py    2001/10/12 20:07:08     1.10
> +++ plt/interface.py    2001/10/24 15:05:19
> @@ -498,3 +498,7 @@
>          else:
>              p.SetSize(s1)
>
> +
> +def setActive(active):
> +    global _active
> +    _active = active
>
>
> You can also download the code including a small application from my
> homepage -> homemade software page; it's part of jkext. See files
> gui/plot.py, gui/kplot.py and scripts/plot. I am planning to add some
> more functionality and then release this as a small sample app.
>
> Greetings,
> Jochen
> --
> University of North Carolina                       phone: +1-919-962-4403
> Department of Chemistry                            phone: +1-919-962-1579
> Venable Hall CB#3290 (Kenan C148)                    fax: +1-919-843-6041
> Chapel Hill, NC 27599, USA                            GnuPG key: 44BCCD8E
>





More information about the Scipy-dev mailing list