From: David ASN <asndav@ho...> - 2004-02-20 09:19:33
Hi all, I'm starting to get in matlabplot world :-D
Before it I tried chaco but it doesn't work in Linux, so I want to try this.
I'm trying to develope an oscilloscope and I need it to embed it into a wx
application. i was thinking in derive a class from wxScrolledWindow and
create a Figure inside, is it possible?
I want to know something about the Class Hierarchy in matplotlib, from which
class figure derives, which is the 'main' class (Figure, i hope), where is
the data stored,...
David Asensio Ortega
Encuentra a tu media naranja entre los perfiles que más te gusten. Toda la
magia del romance en MSN Amor & Amistad. http://match.msn.es/
From: John Hunter <jdhunter@ac...> - 2004-02-21 14:51:43
>>>>> "David" == David ASN <asndav@...> writes:
David> Hi all, I'm starting to get in matlabplot world :-D Before
David> it I tried chaco but it doesn't work in Linux, so I want to
David> try this. I'm trying to develope an oscilloscope and I
David> need it to embed it into a wx application. i was thinking
David> in derive a class from wxScrolledWindow and create a Figure
David> inside, is it possible?
Is certainly possible. Have you looked at examples/anim.py and
examples/system_monitor.py? These use GTK, but will show you how to
dynamically update your figure. Both WX and GTK have a mainloop,
which probably means you need to define an update function that
updates your plot along the lines of system_monitor, and then pass
that function to an idle handler in wx.
David> I want to know something about the Class Hierarchy in
David> matplotlib, from which class figure derives, which is the
David> 'main' class (Figure, i hope), where is the data stored,...
I assume you are using the latest matplotlib release 0.50. In this
release, there are two important objects for you. The first is
Figure, which is what the figure command creates and it contains all
the axes, plots, etc... This has nothing to do with wx, The second is
FigureCanvasWx. In backend wx, this derives from wxPanel and so is a
wx widget. It contains your figure.
In the matlab interface, you can access all of these attributes as
manager = get_current_fig_manager()
canvas = manager.canvas # in wx mode, this is FigureCanvasWx
figure = canvas.figure # this is the backend independent Figure instance
In you oscilloscope update function, you will probably want to do
something along the lines of
lines = plot(t, y) # the initial plot at time 0
line = lines # a matplotlib.lines.Line2D instance
# get a new t, y
# this is a made up function, meaning, tell wx's idle handler to call
# update_scope every 100ms
show() # enter the wx mainloop
You don't need to use the matlab interface at all - you can work
directly with the wx widgets if you prefer. See
If you run into more trouble, post some code back here and someone can
probably help you out.