Hi, I am building a wxPython app, and would like to try
> incorporating matplotlib, even though the wx backend is
> reportedly in its development state. Could someone please
> give a snippet of code using the wx backend? Also, do I need
> pygtk even though I intend on using wxPython?
The matplotlib code you write is more or less backend independent
(same for gtk, wx, ps, etc..). You do not need pygtk. You just need
wxpython and Numeric - which are both included in the enthought
edition of python for win32, by the way; http://enthought.com/python.
If you just want to make some figure windows to explore the plotting
commands, you have 2 choices
import matplotlib
matplotlib.use('WX')
from matplotlib.matlab import *
plot([1,2,3])
show()
or
# myscript.py
from matplotlib.matlab import *
plot([1,2,3])
show()
> python myscript.py -dWX
That is, you choose the wx backend either by doing 'use' or -dWX. See
http://matplotlib.sourceforge.net/backends.html for more info.
See the examples dir of the src distro for examples of how to make
plots more sophisticated than [1,2,3].
But I gather from your post that you want to see an example of
embedding the plot in an application. Jeremy, the wx backend
implemented, can probably help you more here. In the mean time, you
might want to look at the FigureManagerWX class in the file
matplotlib/backends/backend_wx.py to see how to embed a plot in a wx
frame.
I recommend you use the latest CVS, which has a number of improvements
over the 0.32 release. If you don't have CVS access, let me know and
I'll send you a snapshot (are you on windows).
John Hunter