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 4686
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 User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| | |