I don't even know where to begin. This is just bizarre. I just picked
up the Gnuplot.py module (a light interface to gnuplot commands) and
was messing around with it today.
I've got a tiny script, but it only works from the command line about
half the time! In the python interpreter, 100%. Ipython, 100%. I'm
not kidding.
#!/bin/env python
import Gnuplot
g = Gnuplot.Gnuplot(debug=1)
g.title('A simple example')
g('set data style linespoints')
g('set terminal png small color')
g('set output "myGraph.png"')
g.plot([[0,1.1], [1,5.8], [2,3.3], [3,100]])
Here's just one example -- it does not work, then it works. It seems
totally random. It will work a few times, then it won't for a few
times...
bash-2.05b$ ./myGnu.py
gnuplot> set title "A simple example"
gnuplot> set data style linespoints
gnuplot> set terminal png small color
gnuplot> set output "myGraph.png"
gnuplot> plot '/tmp/tmp5LXAow' notitle
gnuplot> plot '/tmp/tmp5LXAow' notitle
^
can't read data file "/tmp/tmp5LXAow"
line 0: util.c: No such file or directory
bash-2.05b$ ./myGnu.py
gnuplot> set title "A simple example"
gnuplot> set data style linespoints
gnuplot> set terminal png small color
gnuplot> set output "myGraph.png"
gnuplot> plot '/tmp/tmpHMTkpL' notitle
(and it makes the graph image just fine)
I mean what the hell is going on? My permissions on /tmp are wide open
(drwxrwxrwt). It does the same thing when I run as root. And it
_always_ works when I use the interpreter or interactive python.
Any clues would be greatly appreciated. I'm baffled. 9 4639
Are you on NFS or are you using a raid? This may have to do with the time it
takes to access your files, etc.
On Monday 04 April 2005 02:23 pm, syd wrote: I don't even know where to begin. This is just bizarre. I just picked up the Gnuplot.py module (a light interface to gnuplot commands) and was messing around with it today.
I've got a tiny script, but it only works from the command line about half the time! In the python interpreter, 100%. Ipython, 100%. I'm not kidding.
#!/bin/env python import Gnuplot g = Gnuplot.Gnuplot(debug=1) g.title('A simple example') g('set data style linespoints') g('set terminal png small color') g('set output "myGraph.png"') g.plot([[0,1.1], [1,5.8], [2,3.3], [3,100]])
Here's just one example -- it does not work, then it works. It seems totally random. It will work a few times, then it won't for a few times...
bash-2.05b$ ./myGnu.py gnuplot> set title "A simple example" gnuplot> set data style linespoints gnuplot> set terminal png small color gnuplot> set output "myGraph.png" gnuplot> plot '/tmp/tmp5LXAow' notitle
gnuplot> plot '/tmp/tmp5LXAow' notitle ^ can't read data file "/tmp/tmp5LXAow" line 0: util.c: No such file or directory
bash-2.05b$ ./myGnu.py gnuplot> set title "A simple example" gnuplot> set data style linespoints gnuplot> set terminal png small color gnuplot> set output "myGraph.png" gnuplot> plot '/tmp/tmpHMTkpL' notitle
(and it makes the graph image just fine)
I mean what the hell is going on? My permissions on /tmp are wide open (drwxrwxrwt). It does the same thing when I run as root. And it _always_ works when I use the interpreter or interactive python.
Any clues would be greatly appreciated. I'm baffled.
--
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095 http://www.jamesstroud.com/
"syd" <sy*********@gmail.com> writes: I don't even know where to begin. This is just bizarre. I just picked up the Gnuplot.py module (a light interface to gnuplot commands) and was messing around with it today.
I've got a tiny script, but it only works from the command line about half the time! In the python interpreter, 100%. Ipython, 100%. I'm not kidding.
#!/bin/env python import Gnuplot g = Gnuplot.Gnuplot(debug=1) g.title('A simple example') g('set data style linespoints') g('set terminal png small color') g('set output "myGraph.png"') g.plot([[0,1.1], [1,5.8], [2,3.3], [3,100]])
Here's just one example -- it does not work, then it works. It seems totally random. It will work a few times, then it won't for a few times...
bash-2.05b$ ./myGnu.py gnuplot> set title "A simple example" gnuplot> set data style linespoints gnuplot> set terminal png small color gnuplot> set output "myGraph.png" gnuplot> plot '/tmp/tmp5LXAow' notitle
gnuplot> plot '/tmp/tmp5LXAow' notitle ^ can't read data file "/tmp/tmp5LXAow" line 0: util.c: No such file or directory
bash-2.05b$ ./myGnu.py gnuplot> set title "A simple example" gnuplot> set data style linespoints gnuplot> set terminal png small color gnuplot> set output "myGraph.png" gnuplot> plot '/tmp/tmpHMTkpL' notitle
(and it makes the graph image just fine)
I mean what the hell is going on? My permissions on /tmp are wide open (drwxrwxrwt). It does the same thing when I run as root. And it _always_ works when I use the interpreter or interactive python.
Any clues would be greatly appreciated. I'm baffled.
What's your OS? Python version? Gnuplot.py version (I assume 1.7)?
Put a 'import sys; print sys.version' in there to make sure /bin/env
is using the same python as you expect it to.
It looks like any temporary file it's writing to is deleted too early.
Have a look at gp_unix.py in the Gnuplot source. There's some
customization options that might be helpful. In particular, I'd try
import Gnuplot
Gnuplot.GnuplotOpts.prefer_fifo_data = 0
.... then the data will be save to a temporary file instead of piped
through a fifo.
Alternatively, try
Gnuplot.GnuplotOpts.prefer_inline_data = 1
.... then no file will be used.
[I don't use Gnuplot myself; this is just what I came up with after a
few minutes of looking at it]
--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
I had similar problems with Gnuplot.py, basically, one couldn't use ascii
mode for plotting grid data, and had to set binary=1 in the GridData()
method. (this is off the top of my head, so I might have the binary/ascii
thing the wrong way around). What fixed the problem was going to version
Gnuplot.py 1.7. What version are you using? If it's 1.6, that *might* be
the problem (although, I can't be 100% sure).
HTH
Regards,
Paul
* syd (sy*********@gmail.com) [050405 07:26]: I don't even know where to begin. This is just bizarre. I just picked up the Gnuplot.py module (a light interface to gnuplot commands) and was messing around with it today.
I've got a tiny script, but it only works from the command line about half the time! In the python interpreter, 100%. Ipython, 100%. I'm not kidding.
#!/bin/env python import Gnuplot g = Gnuplot.Gnuplot(debug=1) g.title('A simple example') g('set data style linespoints') g('set terminal png small color') g('set output "myGraph.png"') g.plot([[0,1.1], [1,5.8], [2,3.3], [3,100]])
Here's just one example -- it does not work, then it works. It seems totally random. It will work a few times, then it won't for a few times...
bash-2.05b$ ./myGnu.py gnuplot> set title "A simple example" gnuplot> set data style linespoints gnuplot> set terminal png small color gnuplot> set output "myGraph.png" gnuplot> plot '/tmp/tmp5LXAow' notitle
gnuplot> plot '/tmp/tmp5LXAow' notitle ^ can't read data file "/tmp/tmp5LXAow" line 0: util.c: No such file or directory
bash-2.05b$ ./myGnu.py gnuplot> set title "A simple example" gnuplot> set data style linespoints gnuplot> set terminal png small color gnuplot> set output "myGraph.png" gnuplot> plot '/tmp/tmpHMTkpL' notitle
(and it makes the graph image just fine)
I mean what the hell is going on? My permissions on /tmp are wide open (drwxrwxrwt). It does the same thing when I run as root. And it _always_ works when I use the interpreter or interactive python.
Any clues would be greatly appreciated. I'm baffled.
-- http://mail.python.org/mailman/listinfo/python-list
--
Paul Cochrane
Computational Scientist/Software Developer
Earth Systems Science Computational Centre
Rm 703, SMI Building
University of Queensland
Brisbane
Queensland 4072
Australia
syd wrote: I don't even know where to begin. This is just bizarre. I just picked up the Gnuplot.py module (a light interface to gnuplot commands) and was messing around with it today.
I've got a tiny script, but it only works from the command line about half the time! In the python interpreter, 100%. Ipython, 100%. I'm not kidding.
Nothing strange about it. When run standalone, the python interpreter quits and
cleans up after itself, possibly deleting temp files before gnuplot gets a
chance to use them. You can put a time.sleep(5) before exiting, or even safer,
a full safety check:
while 1:
if os.path.isfile(your_plot_filename):
break
time.sleeep(1)
Best,
f
syd wrote: I don't even know where to begin. This is just bizarre. I just picked up the Gnuplot.py module (a light interface to gnuplot commands) and was messing around with it today.
I've got a tiny script, but it only works from the command line about half the time! In the python interpreter, 100%. Ipython, 100%. I'm not kidding.
Nothing strange about it. When run standalone, the python interpreter quits and
cleans up after itself, possibly deleting temp files before gnuplot gets a
chance to use them. You can put a time.sleep(5) before exiting, or even safer,
a full safety check:
while 1:
if os.path.isfile(your_plot_filename):
break
time.sleeep(1)
Best,
f
Thanks for all the help, guys!
The affected computer is at home, but I'll address all these issues
before I post again with my fix.
James: It's on my personal box, and I've got reiserfs.
David:
OS: GNU/Linux 2.4 (Gentoo)
Python 2.3
GNUplot 1.6
I just checked the Gentoo Portage tree and 1.7 is listed "~x86"
(unstable), so unwittingly I had gotten 1.6 when I emerged gnuplot-py.
Definitely, the first thing I'm going to do is upgrade to 1.7.
Before I do, though, I'll try to see if this works:
Gnuplot.GnuplotOpts.prefer_fifo_data = 0
Gnuplot.GnuplotOpts.prefer_inline_data = 1
It sounds like Paul had the same problem. I'll also try the "binary =
1" before I upgrade.
Fernando, that's a creative solution, I'll try it as well...
while 1:
if os.path.isfile(your_plot_filename):
break
time.sleep(1)
Thanks guys!
syd wrote: Thanks for all the help, guys!
Fernando, that's a creative solution, I'll try it as well... while 1: if os.path.isfile(your_plot_filename): break time.sleep(1)
More like a desperate brute force one, but it gets the job done :) You
mentioned having ipython, so you can look in the Gnuplot2 module there, around
line 630. You'll see the lengths ipython goes to to ensure that .eps files are
properly created if you call plot() with a filename argument. That solution
has a cutoff, it tries 20 times and eventually gives up if it still doesn't
work. You may want to implement something similar, to avoid endlessly waiting
for your plot in case there is a more serious problem preventing the file from
being created at all.
On a different note, you might want to check out matplotlib. I held out as a
diehard gnuplot user for a long time, waiting for matplotlib to become
production ready (I've been using gnuplot since 1991!). But mpl has really
matured recently, and it offers a level of sophistication and features that
gnuplot simply can't match. Give it a try, you may like it. I've moved my
production code to it, and couldn't be happier. The gnuplot support will
remain in ipython for those who like it, but I won't be adding further features
to it (not that it has changed much in a while, as it's pretty solid).
best,
f
Ok yall, here's my summary. Thanks again for all the help.
Most importantly, upgrading to gnuplot-py 1.7 fixes this problem.
In gnuplot-py 1.6, this is the bottom line...
Does not fix:
Gnuplot.GnuplotOpts.prefer_fifo_data = 0
Fixes:
Gnuplot.GnuplotOpts.prefer_inline_data = 1
Fixes: (placed between setting output and plot)
while 1:
if os.path.isfile("myGraph.png"):
break
time.sleep(1)
As for matplotlib, I checked it out. Looks amazing! I really, really
like what demos I tried.
HOWEVER, I could not find a good way to do smoothing. I like the
gnuplot bezier smoothing. This wouldn't be the hardest thing in the
world to code, but I was a little disappointed. If yall have any
ideas, bring em on! :)
>>>>> "syd" == syd <sy*********@gmail.com> writes:
syd> As for matplotlib, I checked it out. Looks amazing! I
syd> really, really like what demos I tried.
syd> HOWEVER, I could not find a good way to do smoothing. I like
syd> the gnuplot bezier smoothing. This wouldn't be the hardest
syd> thing in the world to code, but I was a little disappointed.
syd> If yall have any ideas, bring em on! :)
What is the gnuplot interface to use smoothing?
When I want to do something like this, I use scipy's interpolate
module and pass the reults to matplotlib for plotting.
from scipy import arange, sin, pi, interpolate
from pylab import plot, show
t = arange(0, 2.0, 0.1)
y = sin(2*pi*t)
tck = interpolate.splrep(t, y, s=0)
tnew = arange(0, 2.0, 0.01)
ynew = interpolate.splev(tnew, tck, der=0)
plot(t, y, 'o', tnew, ynew)
show() This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Richard |
last post by:
I am going to need to plot some data and formula results from Python. A
few years ago I used gnuplot (not from Python) and was wondering which
Python plotting module I should use (learn)?
I...
|
by: Rama Calaga |
last post by:
Hi, I use both python and gnuplot a lot, but I am
unable to find a way to embed gnuplot "window/canvas" into tkinter. BLT option in
PMW is not so powerful and not so great, any suggestions ??
...
|
by: Blues |
last post by:
Hey,
I have used two great models - Tkinter and Gnuplot.py - for a while. I
can display an image on a Canvas widget using Tkinter and I can also
generate a gnuplot from Python on the fly in a...
|
by: Joseph Suprenant |
last post by:
Hello all,
I have a C++ program, it does some calculations on things and then
prints out a file in the format in which GNUPLOT can use. So my question is
how would i call GNUPLOT from my C++...
|
by: Nicola Kaiser |
last post by:
Hi,
I´m using Gnuplot via gnuplot.py and I´m looking for a way to get the
plotting output (terminal set to png in my case) piped in a string
instead of to stdout or a file.
Is there any...
|
by: bwaha |
last post by:
I've posted this question to comp.graphics.apps.gnuplot too but given that
this python group may also comprise a lot of gnuplot users, and is far more
active, I've posted this question here too. My...
|
by: Xah Lee |
last post by:
in March, i posted a essay “What is Expressiveness in a Computer
Language”, archived at:
http://xahlee.org/perl-python/what_is_expresiveness.html
I was informed then that there is a academic...
|
by: zensunni |
last post by:
The script I've made checks for identical fields in the database before it inserts a new row. However, there is one number that, when checked for, will not be found. It assumes there is no row, so it...
|
by: Blah |
last post by:
I'm trying to use the system() in a C++ program to execute gnuplot on
a file of data on OSX and have the graph pop up but so far the only
thing I've managed to do is get gnuplot to open.
as I...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
| | |