From: Ryan K. <rya...@gm...> - 2007-03-20 00:15:30
|
Thanks to Ken and John, I think I am off and running. Nice work on wxmpl Ken! I think it fills a significant need. The two attached files show a ridiculously simple example of what I am planning to do. It may be completely obvoius to others. test_plot.py is an example of a module that can be used from the command line with pylab and IPython and it can also be imported into a WX app (as demonstrated by wx_compatible.py). So, I will edit my data processing scripts to use this approach. Thanks again, Ryan On 3/19/07, Ryan Krauss <rya...@gm...> wrote: > Sorry, I just googled wxmpl and found your page and am now downloading > it. I may have a more intelligent question momentarily. You may > ignore that part of my response. > > Ryan > > On 3/19/07, Ryan Krauss <rya...@gm...> wrote: > > Thanks for your thoughts Ken. Sorry, I assumed a bit on the context > > of my comments. I have some data processing utility scripts and I > > want to now use with a WX application. The problem is that the > > utility modules were written without any thought of this future use in > > mind and in all of them I have something like > > > > from pylab import figure, cla, clf, plot, semiliogx, show, ... > > > > at the top. This makes them completely incompatible with embedding in > > a WX application. So, I need to re-write them and I want to know how > > to do that best. John had some suggestions and I had some new > > questions as I tried to act on his thoughts. So, the actual plotting > > functions don't have to be re-useable in both contexts, but it would > > be nice. > > > > I can't actually run your code because I don't have the wxmpl.py > > module. Looking at it, it looks like a really nice set of functions > > that work cleanly with embedding in a backend. How could I call one > > of the functions from the command line? Could I do something like: > > import plotting, pylab > > myfig = pylab.figure() > > plotting.plot_simple(myfig) > > > > and would I need any additional commands to actually show the figure? > > > > Let me know if that makes sense and please send me the wxmpl.py file > > or let me know where I can get it. > > > > Thanks again, > > > > Ryan > > > > On 3/19/07, Ken McIvor <mc...@ii...> wrote: > > > Ryan, > > > > > > In my (limited) experience, it's dicey to mix pylab's plotting > > > functionality and the OO API. I guess I'm a little unclear exactly > > > what your use case is for this. It sounds like you're goal is to > > > create a library of functions that operate on Figure instances, > > > perhaps so you can use them both interactively and as part of a > > > wxPython application. > > > > > > If that's the case, I'd recommend you try using pylab's gcf() and draw > > > () to acquire and redraw the current Figure instance from within > > > IPython. You can also save the return value of pylab's figure(), > > > which returns a Figure that's already been attached to the > > > appropriate renderer. This way you can use the OO API for plotting > > > without having to futz with the drawing machinery directly. > > > > > > This script might give you some ideas about how to structure your > > > code. It contains several of the MPL examples re-coded as functions > > > that accept a Figure instance and use the OO API for plotting. > > > > > > http://svn.csrri.iit.edu/mr-software/wxmpl/trunk/demos/plotting.py > > > > > > Ken > > > > > > |