[SciPy-user] 3d plotting question

Lance Boyle lanceboyle at cwazy.co.uk
Wed Sep 28 22:30:22 CDT 2005

I might have posted this little bit of code before, but it's not too  
much so I hope no one minds seeing it again. It's not mine, so for  
proper cretids, Google a unique-looking line and it should pop right  
up. With this, you can get to gnuplot with a minimum of fuss. Note  
that it sets up AquaTerm (that's a "plotting terminal" for OS X that  
uses native antialiased graphics with PDF saving, etc. If you don't  
use it, delete the line or set to your own terminal.

import os
class gnuplot:
     def __init__(self):
         print "opening new gnuplot session..."
         self.session = os.popen("gnuplot","w")
     def __del__(self):
         print "closing gnuplot session..."
     def send(self, cmd):
if __name__=="__main__":
     g1 = gnuplot()
     g1.send("set terminal aqua 0")

     # Your code here
     g1.send("plot sin(x)")

     del g1

On Sep 28, 2005, at 2:57 PM, Ryan Krauss wrote:

> You can actually use Gnuplot from Python.  I have had the best luck  
> with  the Gnuplot.py package (http://gnuplot-py.sourceforge.net/).   
> If it doesn't implement the features you want, you can send pure  
> gnuplot code from your python script to the gnuplot session.
> Mayavi is pretty good but I think a bit more complicated (http:// 
> mayavi.sourceforge.net/).  It can do some neat animations.  But, it  
> doesn't do as nice a job of generating post-script files as  
> gnuplot.  I use mayavi for animations and gnuplot.py for print  
> quality graphics.
> Ryan
> Yaroslav Bulatov wrote:
>> There are so many 3d plotting packages, but I'm looking for something
>> simple that'll resemble 3d plots of Gnuplot/Mathematica, can someone
>> recommend one?
>> --
>> Yaroslav Bulatov
>> bulatov at cs.oregonstate.edu
>> Dearborn 102
>> Oregon State University
>> Corvallis, OR
>> _______________________________________________
>> SciPy-user mailing list
>> SciPy-user at scipy.net
>> http://www.scipy.net/mailman/listinfo/scipy-user
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user

More information about the SciPy-user mailing list