468,549 Members | 2,250 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,549 developers. It's quick & easy.

Connecting to gnuplot with Popen?

Hi,

it seems to be a FAQ, but I still haven't found a solution. I want to
control gnuplot with a python program. The following at least gives me the
gnuplot output:

subp=Popen("gnuplot",stdin=None,stderr=PIPE,stdout =PIPE)
....
subp.stderr.readline()

even though I'm not sure how to check if no more lines can be read with
readline() so that it doesn't block.
But after the script has finished, the console doesn't show me the
characters I type.

However, as soon as I try:

subp=Popen("gnuplot",stdin=PIPE,stderr=PIPE,stdout =PIPE)
....
subp.stderr.readline()

the program hangs.

What's wrong?

Anton
Mar 30 '06 #1
5 4665
On Thu, 30 Mar 2006 12:59:01 +0200,
Anton81 <fo***@anton.e4ward.com> wrote:
it seems to be a FAQ, but I still haven't found a solution. I want to
control gnuplot with a python program ...


Unfortunately, I don't know how to solve your problem, but try this:

http://gnuplot-py.sourceforge.net/

Regards,
Dan

--
Dan Sommers
<http://www.tombstonezero.net/dan/>
"I wish people would die in alphabetical order." -- My wife, the genealogist
Mar 30 '06 #2
> I want to control gnuplot with a python program.

Hi Anton,

here is a little snippet using os.popen:
import os

gp = os.popen('gnuplot -persist', 'w')
print >> gp, "set yrange [-300:300]"
for n in range(300):
print >> gp, "plot %i*cos(x)+%i*log(x+10)" % (n,150-n)
Regards, mawe

Mar 31 '06 #3
> Hi Anton,

here is a little snippet using os.popen:


Unfortunately I'm having more problem getting the output from Gnuplot, which
I'd like to examine for error messages and settings of options.

Anton
Mar 31 '06 #4
Anton81 a crit :
Hi,

it seems to be a FAQ, but I still haven't found a solution. I want to
control gnuplot with a python program. The following at least gives me the
gnuplot output:


Unless you absolutely need to write your own code, you should try:
http://gnuplot-py.sourceforge.net/

A+

Laurent.
Mar 31 '06 #5
Anton81 <fo***@anton.e4ward.com> writes:
Hi Anton,

here is a little snippet using os.popen:


Unfortunately I'm having more problem getting the output from Gnuplot, which
I'd like to examine for error messages and settings of options.


If you must roll your own, look at standard module subprocess.
John

Apr 1 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Rama Calaga | last post: by
6 posts views Thread by Joseph Suprenant | last post: by
1 post views Thread by Nicola Kaiser | last post: by
reply views Thread by bwaha | last post: by
3 posts views Thread by Peter Beattie | last post: by
1 post views Thread by mkxc | last post: by
2 posts views Thread by Blah | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.