[Numpy-discussion] [Matplotlib-users] Nonblocking Plots with Matplotlib

Andrew Straw strawman@astraw....
Thu Mar 15 03:07:20 CDT 2007


Bill, very cool. Also, thanks for showing me how Twisted can be used 
like Pyro, more-or-less, I think. (If I understand your code from my 1 
minute perusal.)

On Mac OS X, there's one issue I don't have time to follow any further: 
sys.executable points to  
/Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/MacOS/Python
whereas /Library/Frameworks/Python.framework/Versions/Current/bin/python 
is the file actually on my path. For some reason, when I run the latter 
ezplot is found, when the former, it is not. Thus, your auto-spawning of 
a plotserver instance fails on my installation.

Other than that, the example you gave works as advertised and looks 
great. (Ohh, those anti-aliased lines look better and better the more I 
suffer through my colleagues' aliased plots...)

Bill Baxter wrote:
> Howdy Folks,
>
> I was missing the good ole days of using Matlab back at the Uni when I
> could debug my code, stop at breakpoints and plot various data without
> fear of blocking the interpreter process.
>
> Using "ipython -pylab" is what has been suggested to me in the past,
> but the problem is I don't do my debugging from ipython.  I have a
> very nice IDE that works very well, and it has a lovely interactive
> debugging prompt that I can use to probe my code when stopped at a
> breakpoint.  It's great except I can't really use matplotlib for
> debugging there because it causes things to freeze up.
>
> So I've come up with a decent (though not perfect) solution for
> quickie interactive plots which is to run matplotlib in a separate
> process.  I call the result it 'ezplot'.  The first alpha version of
> this is now available at the Cheeseshop.  (I made an egg too, so if
> you have setuptools you can do "easy_install ezplot".)
>
> The basic usage is like so:
>
>  In [1]: import ezplot
>  In [2]: p = ezplot.Plotter()
>  In [3]: p.plot([1,2,3],[1,4,9],marker='o')
>  Connecting to server... waiting...
>  connected to plotserver 0.1.0a1 on http://localhost:8397
>  Out[3]: True
>  In [4]: from numpy import *
>  In [5]: x = linspace(-5,5,20)
>  In [13]: p.clf()
>  Out[13]: True
>  In [14]: p.plot(x, x*x*log(x*x+0.01))
>
> (Imagine lovely plots popping up on your screen as these commands are typed.)
>
> The only return values you get back are True (success...probably) or
> False (failure...for sure).  So no fancy plot object manipulation is
> possible.  But you can do basic plots no problem.
>
> The nice part is that this (unlike ipython's built-in -pylab threading
> mojo) should work just as well from wherever you're using python.
> Whether it's ipython (no -pylab) or Idle, or a plain MS-DOS console,
> or WingIDE's debug probe, or SPE, or a PyCrust shell or whatever.  It
> doesn't matter because all the client is doing is packing up data and
> shipping over a socket.  All the GUI plotting mojo happens in a
> completely separate process.
>
> There are plenty of ways this could be made better, but for me, for
> now, this probably does pretty much all I need, so it's back to Real
> Work.  But if anyone is interested in making improvements to this, let
> me know.
>
> Here's a short list of things that could be improved:
> * Right now I assume use of the wxAGG backend for matplotlib.  Don't
> know how much work it would be to support other back ends (or how to
> go about it, really).   wxAGG is what I always use.
> * Returning more error/exception info from the server would be nice
> * Returning full fledged proxy plot objects would be nice too, but I
> suspect that's a huge effort
> * SOAP may be better for this than xmlrpclib but I just couldn't get
> it to work (SOAPpy + Twisted).
> * A little more safety would be nice.  Anyone know how to make a
> Twisted xmlrpc server not accept connections from anywhere except
> localhost?
> * There's a little glitch in that the spawned plot server dies with
> the parent that created it.  Maybe there's a flag to subprocess.Popen
> to fix that?
> * Sometimes when you click on "Exit Server", if there are plot windows
> open it hangs while shutting down.
>
>
> Only tested on Win32 but there's nothing much platform specific in there.
>
> Give it a try and let me know what you think!
>
> --bb
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   



More information about the Numpy-discussion mailing list