1
# $Id: FAQ.txt 294 2006-11-07 02:33:08Z parejkoj $
3
Frequently Asked Questions
5
This file is meant to answer the most frequently asked questions about
6
the Gnuplot.py package. If you want to suggest additional questions
7
(with or without answers!) please mail them to the Gnuplot.py users
8
mailing list, <gnuplot-py-users@lists.sourceforge.net>.
10
======================================================================
14
When running the following script
16
------------------------------------------------
19
import Gnuplot, Gnuplot.funcutils
23
g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]])
24
------------------------------------------------
28
gnuplot> plot '/tmp/@24463.2'
30
can't read data file "/tmp/@24463.2"
31
line 0: (No such file or directory)
33
However, the same commands work fine if I type them into the
34
interpreter! What's wrong?
38
The problem is that in many cases Gnuplot.py sends data to gnuplot via
39
a temporary file. But Gnuplot.py has no way of knowing when it is
40
safe to delete the temporary file. So it deletes it when the
41
corresponding PlotItem object is deleted, which is typically when the
42
next Gnuplot.plot() command is executed or when the python script
43
ends. (Until you plot something else, the Gnuplot object keeps a
44
reference to all of the old plot items to prevent their being garbage
47
To prevent this problem, there are several possibilities:
49
1. Switch to Unix. On that platform, Gnuplot.py now uses FIFOs (named
50
pipes) by default to send data to gnuplot. This seems to provide a
51
robust and somewhat elegant solution to this problem.
53
2. Use "inline data" instead of temporary files to communicate with
54
gnuplot. This is already available in gnuplot for most plotting
55
modes if you specify the "inline=1" option to the constructor of
56
the Data object, or if you set GnuplotOpts.prefer_inline_data=1.
57
Since inline data doesn't involve temporary files, the problem goes
60
3. Introduce a delay between the time you plot and the time you allow
61
the Data object to be deleted. You could just use time.sleep(), or
62
if you are producing a graphics file you might watch for the
63
creation of the output file and at that point assume that gnuplot
64
is done with the temporary file. One idea is to explicitly create
65
a PlotItem to represent the data, and keep a reference to the
66
PlotItem for some time after the plot() command is executed; e.g.,
68
data = Gnuplot.Data([[0,1.1], [1,5.8], [2,3.3], [3,4.2]])
70
# ... do something guaranteed to last a couple seconds
71
del data # temporary file is deleted at this moment
73
4. Change Gnuplot.py itself to implement two-way communication between
74
gnuplot and Gnuplot.py. Then, for example, Gnuplot.py could delete
75
temporary files when the next gnuplot prompt appears. This would
76
be a lot of work but it would allow other new features such as
77
detecting gnuplot errors, reading gnuplot fit command output back
80
======================================================================
84
Does Gnuplot.py work under Jython/Java?
88
Partly. Version 1.7 added the low-level interface gp_java.py for
89
communicating with gnuplot using the Java libraries, and that part
92
However, Gnuplot.py relies on the Python Numeric library, which is a C
93
library. The Jython equivalent, called JNumeric
94
<http://jnumerical.sourceforge.net/>, therefore has to be installed.
95
However, JNumeric is still at beta level, and operation under Jython
96
hasn't been tested much at all, so feedback is welcome!
98
======================================================================
104
I am trying to set up your gnuplot/python package on my mac (osX).
105
The readme file says I need to convert the files to mac text files.
106
The coverter I usually use, maclink, won't handle these files. Can
107
you give me a hint how to convert the files or where to look for help?
111
I don't know. But the same user later reported what worked for him:
113
I did have to convert the files. It may not be true for all mac
114
Python users, but I suspect it is. I'm using a graphical Python
115
development environment called "Python IDE for mac" which may have its
116
own pickiness, but still, it wouldn't even recognize the files in your
117
package as being the type it could open. I tried a few different file
118
converters with no luck. Then I just opened all the files with
119
BBedit, changed something so I would be prompted to save it on closing
120
(like add and remove a letter), and closed BBedit. Then all the files
121
were 'mac' files and the Python interpreter recognised them.
123
======================================================================
127
I am using Windows and I get an error like
129
> Traceback (most recent call last):
131
> File "C:\Python23\Lib\site-packages\Gnuplot\gp_win32.py",
132
> line 125, in __call__
133
> self.write(s + '\n')
134
> IOError: [Errno 22] Invalid argument
140
This is apparently the error that results when Gnuplot.py cannot start
141
the pgnuplot.exe executable under Windows. It could be that gnuplot
142
(the plotting program, as opposed to Gnuplot.py) is not installed, or
143
that it is not in your PATH. If your pgnuplot.exe executable is named
144
differently, or you do not want to add its directory to your PATH, you
145
can change gnuplot_command in gp_win32.py to indicate the precise path