|
From: Ken M. <mc...@ii...> - 2005-12-02 02:08:34
|
On 12/01/05 16:13, Matt Newville wrote:
> Here's what I think the fundamental differences are. Maybe Ken can
> give an opinion too.
My take on things is that WxMpl and MPlot solve two different problems. WxMpl
is intended to be a FigureCanvasWxAgg that has some pointy-clicky user
interactions (e.g. zoom) built in. I gather that Matt considers it "focused
on the programmer/script writer, not on the end user of an application"
because it doesn't provide end-users with any means to edit the plot. MPlot
lets users interactively change the title, axes labels, etc.
I wrote WxMpl after Matt sent me MPlot 0.7 because I felt that his approach
wasn't solving my problem: I was thrilled what matplotlib and wanted *all* of
it to Just Work with wxPython. Allowing users to edit plots was less important
to me than supporting as many kinds of plots as possible. By focusing on
adding user interaction to FigureCanvasWxAgg I was able to support all of
matplotlib's OO API in one fell swoop.
> Like (correct me if I'm wrong, Ken), you'll have to explicitly
> enable/disable zooming, and add your own GUI controls for having user-set
> titles and such, and know that to plot, you need to get the axes from the
> figure and use axes.plot(). I believe there is no user-level way for
> altering the plots made with wxMPL.
Zooming and point-under-cursor are enabled by default. You are correct, WxMpl
provides no GUI tools to allow application users to alter plots.
> To do this, MPlot does make forced choices for bindings -- zooming is by
> dragging a rubberband box, coordinates show up only on left-click, etc (I
> believe that wxMPL also makes similar forced choices.
Yep. I've followed the BLT convention of zooming by selection a rectangular
area and unzooming by right-clicking.
>>if wxMPL is a wx interface for MPL, it seems focusing on the end user is the programmer's
>>task, isn't it? and it seems right to me
>
> With wxMPL it is, and wxMPL gives tools to programmer to make
> applications. With MPlot, much of what you'd want is already built
> in: it is a plotting component ready to be put into an application.
> You could write your own wxHTML widget yourself too, or you could use
> the one that already exists. It's simply a question of using
> pre-existing packaged solutions or rolling your own from lower-level
> parts.
As always, there is a trade off involved. In other words, MPlot would be a
sensible choice if allowing users to edit their plots is very important.
WxMpl makes sense if having access to all of MPL's plotting abilities is very
important. Furthermore, there's nothing stopping someone from adding support
for more kinds of plots to MPlot or from building a plot editor on top of
WxMpl, if they were so inclined.
>>and what do you mean with "wxMPL is not exactly a 'wxpython plot widget'"?
>
> Well, I'd say it's a class library from which one can build wxPython
> plotting widgets.
Well I'd say it's a wxPython plotting widget that lets you build plot editors.
I guess it all depends on your definition of "wxPython plotting widget". :-)
> I don't want to have to use the low-level matplotlib API to say in a
> wxPython Program: 'make a wxPlotter', and 'plot x,y to the wxPlotter'.
As I said earlier, I think we're trying to solve different problems. I do want
to use the low-level matplotlib API, because it's a more flexible and
powerful. If necessary, I want to be able to say in a wxPython program "make
a wxPlotter and then make two subplots, one a line plot with two embedded
axes, the other a histogram and a line plot, and then chain their X axes
together".
> I wanted something at a high enough level that knowledge of matplotlib is
> not necessary for an enduser to use a PlotPanel, or even for a wxPython
> programmer to use it in a program.
I hadn't considered "end users" when writing WxMpl, on the notion that they
weren't going to be writing their own wxPython applications any time soon.
That being said, I have added some convenience classes to make WxMpl easier to
use for ad hoc plotting.
> In my opinion, MPlot ends up looking a lot better than wxPyPlot -- all
> because of matplotlib.
Matplotlib is an incredible piece of software. I agree with you, John
deserves to be knighted.
Ken
P.S. Since Matt posted a short MPlot example, I figured I should post a short
WxMpl counter-example :-P
import wxmpl
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.numerix as nx
dx, dy = 0.025, 0.025
x = nx.arange(-3.0, 3.0, dx)
y = nx.arange(-3.0, 3.0, dy)
X,Y = mlab.meshgrid(x, y)
Z = (1- X + X**5 + Y**3)*nx.exp(-X**2-Y**2)
class MyPlotApp(wxmpl.PlotApp):
ABOUT_TITLE = 'WxMpl Example'
ABOUT_MESSAGE='Behold! An example!\nCopyright 2005 Yoyodyne Inc'
app = MyPlotApp(title='WxMpl Example')
figure = app.get_figure()
axes = figure.gca()
img = axes.imshow(Z, cmap=cm.jet, extent=(-3, 3, -3, 3))
figure.colorbar(img)
axes.set_title('$(1 - X + X^5 + Y^3)*e^{\/^{(-X^2-Y^2)}}$')
axes.set_xlabel('X Axis')
axes.set_ylabel('Y Axis')
app.MainLoop()
|