Re: [SciPy-user] gplt and xplt
David, I'd recommend you look (for mature cross platform packages for Python) at gnuplot.py, Matplotlib and, if you need certain plot types not supported by these, DISLIN (and disipyl). I've mucked around with others but have rejected them for one reason or other. Gary ----- Original Message ----- From: "David J. Grant" <david.grant@telus.net> Date: Wed, 11 Aug 2004 14:10:16 -0700 To: SciPy Users List <scipy-user@scipy.net>,Steve Schmerler <elcorto@gmx.net> Subject: Re: [SciPy-user] gplt and xplt
This is a HUGE problem with gplt. There is a long sleep command somewhere in the code. This is necessary because when piping data to gnuplot some kind of badness happens if you do it too fast.
There are a ton of plotters for Python out there. Finding the right one is the problem. The community really needs one that can do everything reliably, fast, and on all platforms. Or a very robust wrapper which can call all sorts of Python plotters. If anyone knows anything of use, please let me know.
David
-- ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm
David, I'd recommend you look (for mature cross platform packages for Python) at gnuplot.py, Matplotlib and, if you need certain plot types not supported by these, DISLIN (and disipyl). I've mucked around with others but have rejected them for one reason or other. Gary
Hi I tried gnuplot.py and I'm impressed. It's more straightforward than gplt and _much_ faster (almost as fast as using gnuplot directly). Thanx steve -- If you can't beat your computer at chess, try kickboxing. -- NEU: WLAN-Router f�r 0,- EUR* - auch f�r DSL-Wechsler! GMX DSL = superg�nstig & kabellos http://www.gmx.net/de/go/dsl
Quoting Steve Schmerler <elcorto@gmx.net>:
I tried gnuplot.py and I'm impressed. It's more straightforward than gplt and _much_ faster (almost as fast as using gnuplot directly).
If you want to use gnuplot.py, you may want to try ipython (http://ipython.scipy.org). It layers extra functions on top of Gnuplot.py which provide better syntax for many common tasks. You can use it interactively (the provided 'numeric' profile loads Numeric and the gnuplot support), or in scripts; the basic support module is IPython.GnuplotRuntime. Best, f
On Thu, 2004-08-12 at 09:09, Fernando.Perez@colorado.edu wrote:
If you want to use gnuplot.py, you may want to try ipython
Fernando is too modest. If you want to do _anything_ with Python, you owe it to yourself to try ipython. Perhaps it is the fervor of the recently converted, but I'm a big fan of it. "ipython -p pysh" is a wonder. -- Stephen Walton <stephen.walton@csun.edu> Dept. of Physics & Astronomy, Cal State Northridge
Stephen Walton wrote:
On Thu, 2004-08-12 at 09:09, Fernando.Perez@colorado.edu wrote:
If you want to use gnuplot.py, you may want to try ipython
Fernando is too modest. If you want to do _anything_ with Python, you owe it to yourself to try ipython. Perhaps it is the fervor of the recently converted, but I'm a big fan of it.
"ipython -p pysh" is a wonder.
<blush> Many thanks for the kind comment. I really appreciate it. I have no idea how wide the ipython userbase is, and most projects (ipython is not alone here) tend to hear from users only when there are bugs or missing features. I work on ipython for fun and because I use it all day for my own research, so I don't _expect_ any kind of 'reward'. But this kind of response is one of the small joys of working on something which turns out to be valued by others. So with all sincerity, thank you. Best, f ps. I'm glad you like pysh, I think it's a pretty cool feature. Coming soon: gtk support so you can use matplotlib (or any other gtk/wx based program) with ipython, with transparent mainloop thread support. I'll try to post a pre-release of this tomorrow on the ipython list.
On Thu, 12 Aug 2004, Stephen Walton apparently wrote:
If you want to do anything with Python, you owe it to yourself to try ipython. Perhaps it is the fervor of the recently converted, but I'm a big fan of it.
OK. I use Windows 2000. I installed ctypes. I installed readline. I installed IPython. IPython failes with a call to readline.set_completer: AttributeError: module has no attribute set_completer Any ideas? Thanks, Alan Isaac
Alan G Isaac wrote:
On Thu, 12 Aug 2004, Stephen Walton apparently wrote:
If you want to do anything with Python, you owe it to yourself to try ipython. Perhaps it is the fervor of the recently converted, but I'm a big fan of it.
OK. I use Windows 2000. I installed ctypes.
Which version? There's a notice at http://ipython.scipy.org about a problem with 0.9 & unc-readline, which is the current one. This is unfortunate, but beyond my control. The unc-readline author is working on it, but for now the only solution is to backpedal to ctypes 0.6.
I installed readline.
Which one? The unc-readline, from: http://sourceforge.net/projects/uncpythontools is the only one that works correctly. The one here: http://newcenturycomputers.net/projects/readline.html is terminally broken, don't use it. It's not a real readline, it misses critical parts of the api.
I installed IPython.
IPython failes with a call to readline.set_completer: AttributeError: module has no attribute set_completer
Any ideas?
I hope this helps, let me know if you need more assistance. Unfortunately things under Windows are always harder than with posix systems, due to the brokenness of many of the necessary underlying subsystems. The fact that I can't test it because I don't have access to a computer running windows anywhere doesn't help. But with user's help (like Gary Bishop, the uncreadline author), ipython under Win32 has actually made a lot of progress. Best, f
Alan G Isaac wrote:
On Thu, 12 Aug 2004, Stephen Walton apparently wrote:
If you want to do anything with Python, you owe it to yourself to try ipython. Perhaps it is the fervor of the recently converted, but I'm a big fan of it.
OK. I use Windows 2000. I installed ctypes.
On Fri, 13 Aug 2004, Fernando Perez apparently wrote:
There's a notice at http://ipython.scipy.org about a problem with 0.9 & unc-readline, which is the current one.
This is unfortunate, but beyond my control. The unc-readline author is working on it, but for now the only solution is to backpedal to ctypes 0.6.
Will this involve anything beyond deleting the ctypes folder and then installing 0.6?
The unc-readline, from: http://sourceforge.net/projects/uncpythontools is the only one that works correctly.
That's the one I used. Thanks, Alan Isaac
----- Original Message ----- From: "Alan G Isaac" <aisaac@american.edu> To: "SciPy Users List" <scipy-user@scipy.net> Sent: Friday, August 13, 2004 6:07 PM Subject: Re[2]: [SciPy-user] gplt and xplt
On Fri, 13 Aug 2004, Fernando Perez apparently wrote:
There's a notice at http://ipython.scipy.org about a problem with 0.9 & unc-readline, which is the current one.
This is unfortunate, but beyond my control. The unc-readline author is working on it, but for now the only solution is to backpedal to ctypes 0.6.
Will this involve anything beyond deleting the ctypes folder and then installing 0.6?
I just installed the old one over the new one and it worked fine. ymmv. Fernando, maybe you should put a note on the web site about this. I did a new install on a new machine and was quite puzzled for a while...
Gary Pajer wrote:
Will this involve anything beyond deleting the ctypes folder and then installing 0.6?
I just installed the old one over the new one and it worked fine. ymmv.
Fernando, maybe you should put a note on the web site about this. I did a new install on a new machine and was quite puzzled for a while...
Mmh, have you been to the page recently? :) http://ipython.scipy.org/ It's been there since Aug. 3, after I started getting reports about the problem. I'll take it down if a solution comes along (which I expect to happen, Gary Bishop is working on it). Best, f
----- Original Message ----- From: "Fernando Perez" <Fernando.Perez@colorado.edu>
Gary Pajer wrote:
Will this involve anything beyond deleting the ctypes folder and then installing 0.6?
I just installed the old one over the new one and it worked fine. ymmv.
Fernando, maybe you should put a note on the web site about this. I did a new install on a new machine and was quite puzzled for a while...
Mmh, have you been to the page recently? :)
It's been there since Aug. 3,
The problem is that the font is too big, and it's too close to the top of the page. If you had written it in a tiny hard to read font, and buried it on page six, I would have seen it. :)
Quoting Alan G Isaac <aisaac@american.edu>:
This is unfortunate, but beyond my control. The unc-readline author is working on it, but for now the only solution is to backpedal to ctypes 0.6.
Will this involve anything beyond deleting the ctypes folder and then installing 0.6?
I suppose so, but you'll have to give it a try. Best, f
On Thu, 12 Aug 2004, Gary Ruben apparently wrote:
I'd recommend you look (for mature cross platform packages for Python) at gnuplot.py, Matplotlib and, if you need certain plot types not supported by these, DISLIN (and disipyl).
Just to note on the particular issue raised by Gary: gnuplot.py faces exactly the same problem as gplt but relies on the user to implement apprpriate delays. What is unclear from the descriptions that I've read is whether this is a gnuplot problem or a problem with pipes under Windows. If the former, do the gnuplot developers know about it?
I've mucked around with others but have rejected them for one reason or other.
Can you summarize your experience with biggles? http://biggles.sourceforge.net/ Thanks, Alan Isaac
On Thu, Aug 12, 2004 at 10:38:45AM -0400, Alan G Isaac wrote:
On Thu, 12 Aug 2004, Gary Ruben apparently wrote:
I'd recommend you look (for mature cross platform packages for Python) at gnuplot.py, Matplotlib and, if you need certain plot types not supported by these, DISLIN (and disipyl).
Just to note on the particular issue raised by Gary: gnuplot.py faces exactly the same problem as gplt but relies on the user to implement apprpriate delays. What is unclear from the descriptions that I've read is whether this is a gnuplot problem or a problem with pipes under Windows. If the former, do the gnuplot developers know about it?
I've mucked around with others but have rejected them for one reason or other.
Can you summarize your experience with biggles? http://biggles.sourceforge.net/
I like biggles. It has a clean, object-based, API. It uses plotutils, so it can generate all the formats you need, including output to an X window. You generate your curves, etc., and add them to a plot object. It doesn't have a matrix plot, though. [What I don't like about matplotlib, for instance, is its insistence on using matlab commands acting on a global plot instead of acting on plot objects (like biggles does).] -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |cookedm@physics.mcmaster.ca
"David" == David M Cooke <cookedm@physics.mcmaster.ca> writes:
David> [What I don't like about matplotlib, for instance, is its David> insistence on using matlab commands acting on a global plot David> instead of acting on plot objects (like biggles does).] Not quite accurate - there is no insistence on this at all. In fairness, the matlab interface is by far the best documented, but there is an OO API which you can use in a GUIs, in a script, or from the shell. The matlab interface is a very thin wrapper around this API. Here is a simple "pythonic" example using matplotlib with no hidden usage of global objects - more details at http://matplotlib.sourceforge.net/examples/pythonic_matplotlib.py from matplotlib.matlab import figure, close, axes, subplot, show from matplotlib.numerix import arange, sin, pi t = arange(0.0, 1.0, 0.01) fig = figure(1) ax1 = fig.add_subplot(211) ax1.plot(t, sin(2*pi*t)) ax1.grid(True) ax1.set_ylim( (-2,2) ) ax1.set_ylabel('1 Hz') ax1.set_title('A sine wave or two') for label in ax1.get_xticklabels(): label.set_color('r') ax2 = fig.add_subplot(212) ax2.plot(t, sin(2*2*pi*t)) ax2.grid(True) ax2.set_ylim( (-2,2) ) l = ax2.set_xlabel('Hi mom') l.set_color('g') l.set_fontsize('large') show() I actually prefer the matlab style interface because I find it much more pithy, eg xlabel('Hi mom', color='g', fontsize='large') but many people like you prefer the approach above and use matplotlib that way. JDH
On Thu, Aug 12, 2004 at 03:57:02PM -0500, John Hunter wrote:
"David" == David M Cooke <cookedm@physics.mcmaster.ca> writes:
David> [What I don't like about matplotlib, for instance, is its David> insistence on using matlab commands acting on a global plot David> instead of acting on plot objects (like biggles does).]
Not quite accurate - there is no insistence on this at all. In fairness, the matlab interface is by far the best documented, but there is an OO API which you can use in a GUIs, in a script, or from the shell. The matlab interface is a very thin wrapper around this API.
Here is a simple "pythonic" example using matplotlib with no hidden usage of global objects - more details at http://matplotlib.sourceforge.net/examples/pythonic_matplotlib.py
from matplotlib.matlab import figure, close, axes, subplot, show from matplotlib.numerix import arange, sin, pi
t = arange(0.0, 1.0, 0.01)
fig = figure(1)
Hidden variable; the '1' is a global identifier for the plot.
ax1 = fig.add_subplot(211) ax1.plot(t, sin(2*pi*t)) ax1.grid(True) ax1.set_ylim( (-2,2) ) ax1.set_ylabel('1 Hz') ax1.set_title('A sine wave or two')
for label in ax1.get_xticklabels(): label.set_color('r')
ax2 = fig.add_subplot(212) ax2.plot(t, sin(2*2*pi*t)) ax2.grid(True) ax2.set_ylim( (-2,2) ) l = ax2.set_xlabel('Hi mom') l.set_color('g') l.set_fontsize('large')
show()
Again, no hidden globals? Then what does show() do? What does it show? savefig() has the same problem. They both have the concept of "current figure" -- which is a global I don't reference above. In essence, can I build up two plots independently at the same time? Then save them? The biggles version of this is <http://biggles.sourceforge.net/doc/current/example/?n=3> import biggles import math, Numeric x = Numeric.arange( 0, 3*math.pi, math.pi/10 ) y = Numeric.sin(x) p = biggles.FramedPlot() p.title = "Title" p.xlabel = "X axis" p.ylabel = "Y axis" p.add( biggles.Histogram(y) ) p.add( biggles.PlotLabel(.5, .5, "Histogram", color=0xcc0000) ) t1 = biggles.Table( 1, 2 ) t1[0,0] = p t1[0,1] = p t2 = biggles.Table( 2, 1 ) t2[0,0] = t1 t2[1,0] = p t2.write_img( 400, 400, "example3.png" ) t2.write_eps( "example3.eps" ) t2.show() Compared to that, matplotlib just doesn't seem pythonic enough for me. It does have its advantages, though: anti-aliased output, different renderers, and you can add interactivity. -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |cookedm@physics.mcmaster.ca
"David" == David M Cooke <cookedm@physics.mcmaster.ca> writes:
David> Hidden variable; the '1' is a global identifier for the David> plot. OK, good eye. I was playing a little fast and loose. However, the fact remains that you do not need the matlab interface at all. I was using it minimally in my example above. >> show() David> Again, no hidden globals? Then what does show() do? What David> does it show? It provides a consistent interface so that the same script can realize figure windows across the 4 GUI backends: GTK, WX, Tkinter and FLTK. But you're right again - some pixie dust under the hood. David> savefig() has the same problem. They both have the concept David> of "current figure" -- which is a global I don't reference David> above. True, but I didn't call savefig in my example. See below, in any case. David> In essence, can I build up two plots independently David> at the same time? Then save them? Not a problem - here the matlab interface is not imported or used. The use of a separate Figure and FigureCanvas below results from trying to keep a clean separation from the frontend (Figure) and backend (Canvas) from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure from matplotlib.numerix import rand fig1 = Figure() fig2 = Figure() canvas1 = FigureCanvas(fig1) canvas2 = FigureCanvas(fig2) ax1 = fig1.add_subplot(111) ax2 = fig2.add_axes([0.2, 0.2, 0.5, 0.5]) # a custom axes in fig2 ax1.plot([1,2,3]) ax2.scatter(rand(12), rand(12)) canvas1.print_figure('fig1.svg') # switches to the svg backend canvas1.print_figure('fig1.png') # native agg saves png canvas2.print_figure('fig2.eps') # switches to the PS backend No call to show, etc.... The hardcopy is created upon executing this script. Here I take advantage of the fact that most backends (agg in this case) can switch backends to render to PS/EPS/SVG/PNG depending on the extension. You don't need to use the switching feature - you could have directly imported the SVG or PS backend canvas, but I included it for illustration. You use the same approach to create GUI canvases for embedding in an application, but the constructor args for the FigureCanvas vary somewhat from backend to backend. And you would have to fire up your GUI mainloop and realize your windows, etc.. Thanks for keeping me honest! I'm working on a users guide and will include a section along these lines. JDH
On Thu, Aug 12, 2004 at 04:36:20PM -0500, John Hunter wrote:
"David" == David M Cooke <cookedm@physics.mcmaster.ca> writes: David> In essence, can I build up two plots independently David> at the same time? Then save them?
Not a problem - here the matlab interface is not imported or used. The use of a separate Figure and FigureCanvas below results from trying to keep a clean separation from the frontend (Figure) and backend (Canvas)
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure from matplotlib.numerix import rand
fig1 = Figure() fig2 = Figure()
canvas1 = FigureCanvas(fig1) canvas2 = FigureCanvas(fig2)
ax1 = fig1.add_subplot(111) ax2 = fig2.add_axes([0.2, 0.2, 0.5, 0.5]) # a custom axes in fig2
ax1.plot([1,2,3])
ax2.scatter(rand(12), rand(12))
canvas1.print_figure('fig1.svg') # switches to the svg backend canvas1.print_figure('fig1.png') # native agg saves png canvas2.print_figure('fig2.eps') # switches to the PS backend
No call to show, etc.... The hardcopy is created upon executing this script. Here I take advantage of the fact that most backends (agg in this case) can switch backends to render to PS/EPS/SVG/PNG depending on the extension. You don't need to use the switching feature - you could have directly imported the SVG or PS backend canvas, but I included it for illustration.
Hmm, ok. I like that better. Thanks! -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |cookedm@physics.mcmaster.ca
Hi John, John Hunter wrote:
David> In essence, can I build up two plots independently David> at the same time? Then save them?
Not a problem - here the matlab interface is not imported or used. The use of a separate Figure and FigureCanvas below results from trying to keep a clean separation from the frontend (Figure) and backend (Canvas)
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure from matplotlib.numerix import rand
fig1 = Figure() fig2 = Figure()
canvas1 = FigureCanvas(fig1) canvas2 = FigureCanvas(fig2)
ax1 = fig1.add_subplot(111) ax2 = fig2.add_axes([0.2, 0.2, 0.5, 0.5]) # a custom axes in fig2
ax1.plot([1,2,3])
ax2.scatter(rand(12), rand(12))
canvas1.print_figure('fig1.svg') # switches to the svg backend canvas1.print_figure('fig1.png') # native agg saves png canvas2.print_figure('fig2.eps') # switches to the PS backend
No call to show, etc.... The hardcopy is created upon executing this script. Here I take advantage of the fact that most backends (agg in this case) can switch backends to render to PS/EPS/SVG/PNG depending on the extension. You don't need to use the switching feature - you could have directly imported the SVG or PS backend canvas, but I included it for illustration.
You use the same approach to create GUI canvases for embedding in an application, but the constructor args for the FigureCanvas vary somewhat from backend to backend. And you would have to fire up your GUI mainloop and realize your windows, etc..
Thanks for keeping me honest! I'm working on a users guide and will include a section along these lines.
In the script above, how would you make the graphs show to the screen and not just save to a file? Thanks, -- David J. Grant http://www.davidgrant.ca:81
"David" == David Grant <david.grant@telus.net> writes: David> In the script above, how would you make the graphs show to David> the screen and not just save to a file?
Just to make sure we are clear - David Cook asked specifically about using the pure OO API rather than the matlab interface. If all you want to do is show some graphs to the screen, the easiest way is to use the matlab interface (I'll be happy to provide a sample) because it manages all the complexities of creating the navigation toolbar, creating and realizing the figure windows, etc... But I'm assuming you indeed want to know how to use the OO API to show figures to the screen. There are a number of examples in the matplotlib/examples directory of the src distribution (also at http://matplotlib.sourceforge.net/examples). How you do this depends on the GUI package you are using (Tkinter, pygtk, wxpython...). See for example embedding_in_gtk2.py, mbedding_in_tk.py, and embedding_in_wx2.py. Basically, to create multiple figures using the API, you instantiate multiple canvases for the backend of your choice, as in the example above but importing a different canvas, eg FigureCanvasWXAgg. Then you embed these canvases in a GUI window (all the matplotlib GUI FigureCanvases derive from a widget that can be directly embedded in a GUI windowm Let me know if you have any more questions or if these examples above aren't clear. JDH
Alan G Isaac wrote:
http://biggles.sourceforge.net/
Can you summarize your experience with biggles?
Biggles rocks. It is a big more object oriented if I remember, compared to the others. The only problem is no one has built biggles for windows with python 2.3, so in my opinion it is not cross-platform. I have no idea if further windows packages will ever be built for future python versions so that's why I stay away from it as a long term solution. I love the graphs it produces and it is very fast. -- David J. Grant http://www.davidgrant.ca:81
David Grant:
Alan G Isaac wrote:
http://biggles.sourceforge.net/
Can you summarize your experience with biggles?
Biggles rocks. It is a big more object oriented if I remember, compared to the others. The only problem is no one has built biggles for windows with python 2.3, so in my opinion it is not cross-platform. I have no idea if further windows packages will ever be built for future python versions so that's why I stay away from it as a long term solution. I love the graphs it produces and it is very fast.
-- David J. Grant http://www.davidgrant.ca:81
Hmm, I found a Win32 installer for Python 2.3x on the biggles page. bye steve -- If you can't beat your computer at chess, try kickboxing. -- NEU: WLAN-Router f�r 0,- EUR* - auch f�r DSL-Wechsler! GMX DSL = superg�nstig & kabellos http://www.gmx.net/de/go/dsl
Steve Schmerler wrote:
David Grant:
Alan G Isaac wrote:
http://biggles.sourceforge.net/
Can you summarize your experience with biggles?
Biggles rocks. It is a big more object oriented if I remember, compared to the others. The only problem is no one has built biggles for windows with python 2.3, so in my opinion it is not cross-platform. I have no idea if further windows packages will ever be built for future python versions so that's why I stay away from it as a long term solution. I love the graphs it produces and it is very fast.
-- David J. Grant http://www.davidgrant.ca:81
Hmm, I found a Win32 installer for Python 2.3x on the biggles page.
Well that's something very new then. -- David J. Grant http://www.davidgrant.ca:81
participants (10)
-
Alan G Isaac -
David Grant -
David M. Cooke -
Fernando Perez -
Fernando.Perez@colorado.edu -
Gary Pajer -
Gary Ruben -
John Hunter -
Stephen Walton -
Steve Schmerler