From: Samuel H. D. Jr. <sd...@sp...> - 2009-08-10 04:38:03
|
Greetings, I'm attempting to run Gnuplot in Python under IDLE. I'm running Python version. 2.5 on a Power Mac G4 under Mac OS X, version 10.4.11. I've installed Gnuplot-py version 1.8 and I have Gnuplot version 4.2. I have Gnuplot defaulted to display plots using AquaTerm.app version 1.0.1. This has been working fine. When I run the following Python code in a terminal window #example_gnuplot.py from numpy import * import Gnuplot, Gnuplot.funcutils def f(t): return t**2*exp(-t**2) g = Gnuplot.Gnuplot(debug=1) t = linspace(0, 3, 51) # 51 points between 0 and 3 y = zeros(len(t)) # allocate y with float elements for i in xrange(len(t)): y[i] = f(t[i]) g.plot(t, y)* * produces the desired plot with the following listing: dsl092-239-159:~/python programs samueldupree$ python example_gnuplot.py gnuplot> set terminal aqua gnuplot> plot "/tmp/tmpytUeOa.gnuplot/fifo" notitle, "/tmp/tmp-7QSsP.gnuplot/fifo" notitle 2009-08-08 05:07:28.182 gnuplot[1510] libaquaterm::Warning: Logging at level 4 2009-08-08 05:07:28.184 gnuplot[1510] libaquaterm::Launching server... 2009-08-08 05:07:28.564 gnuplot[1510] libaquaterm::LSOpenCFURLRef = 0 2009-08-08 05:07:28.573 gnuplot[1510] libaquaterm::Waiting... 9 2009-08-08 05:07:29.585 gnuplot[1510] libaquaterm::Server version 1.0.1 2009-08-08 05:07:29.586 gnuplot[1510] libaquaterm::Connected! 2009-08-08 05:07:29.755 gnuplot[1510] libaquaterm::Active plot: 0 dsl092-239-159:~/python programs samueldupree$ However, when I attempt to run this program under IDLE, I get no plot whatsoever and IDLE produces the following report: Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "copyright", "credits" or "license()" for more information. **************************************************************** Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet. **************************************************************** IDLE 1.2 >>> ================================ RESTART ================================ >>> gnuplot> set terminal aqua Traceback (most recent call last): File "/Users/samueldupree/python programs/example_gnuplot.py", line 16, in <module> g.plot(t, y) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Gnuplot/_Gnuplot.py", line 285, in plot self.refresh() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Gnuplot/_Gnuplot.py", line 226, in refresh self(self.plotcmd + ' ' + string.join(plotcmds, ', ')) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Gnuplot/_Gnuplot.py", line 210, in __call__ self.gnuplot(s) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Gnuplot/gp_macosx.py", line 144, in __call__ self.flush() IOError: [Errno 32] Broken pipe >>> My questions for the list are: 1. What am I doing wrong? 2. What path variables of parameters do I need to set? 3. Why does my program work when running in a terminal window as opposed to running under IDLE? Sam Dupree. |