[SciPy-user] scipy.gplt versus IPython.GnuplotRuntime

Eni Mustafaraj eni at Mathematik.Uni-Marburg.de
Mon Aug 11 13:35:11 EDT 2003


Hello,

I am interested in dynamically generating plot images for web-pages. I 
looked first at Chaco, but its non-interactive functionalities are not 
very well documented, and so I turned to scipy.gplt, having previously 
worked with gnuplot and  Gnuplot.py (from Sourceforge).
I found scipy.gplt very easy to work with, and it is fine to have a 
direct output of PNG (exactly what I need), but the whole thing is 
rather slow (see the test below).
Afterwards, reading through the Scipy-users archive I found out about 
the IPython.GnuplotRuntime, tried it out, and it's great to see that it 
handles some of the deficiencies of Gnuplot.py, and is so fast compared 
to scipy.gplt.

I just tested the following two examples with "profile" (in the same 
Windows box, with Python 2.2.3):

# Example 1
from scipy import gplt
import Numeric

def myPlot_1():
    x = Numeric.arange(0,10,.1)
    y = Numeric.sin(x)
    gplt.plot(x,y, 'with linespoints lt 3 pt 6')
    gplt.title('Plotting with gplt')
    gplt.output('test_1.png', 'png color')

# Example 2
import Numeric
import IPython.GnuplotRuntime

def myPlot_3():
    gp = IPython.GnuplotRuntime.gp
    Data = IPython.GunplotRuntime.Data
    x = Numeric.arange(0,10,.1)
    y = Numeric.sin(x)
    gp('set title "Plotting with IPython.GnuplotRuntime"')
    gp.plot(Data(x,y,with='linespoints lt 3 pt 6'))   
    gp.hardcopy('test_3.ps', enhanced=1, color=1)

The results:
 >>>  profile.run('myPlot_1()')
 >>>          306 function calls in 2.507 CPU seconds

 >>>  profile.run('myPlot_3()')
 >>> IE
*** Your version of Gnuplot appears not to have mouse support.
         82 function calls in 0.201 CPU seconds

So, I have a couple of questions:

1) Why is scipy.gplt so much slower than IPython.GnuplotRuntime? Well, I 
see it is calling a lot more  functions, but why should it be this way, 
since the result is going to be the same in both examples (except that 
one produces a PNG and the other a Postscript, but the slowness persists 
even when no output file is requested).

2) How to suppress the gnuplot window for both packages? ( since only 
the file ouptut is interesting)

3) Can IPython.GnuplotRuntime also output a PNG file? How?

Thanks for helping, and keep doing the wornderful job!

Eni







More information about the SciPy-User mailing list