~ubuntu-branches/ubuntu/saucy/python-gnuplot/saucy

« back to all changes in this revision

Viewing changes to .pc/fix-python-name.patch/FAQ.txt

  • Committer: Package Import Robot
  • Author(s): Josue Ortega
  • Date: 2013-05-27 00:29:42 UTC
  • mfrom: (7.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130527002942-t2mrk8w2732452t0
Tags: 1.8-4
Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: FAQ.txt 294 2006-11-07 02:33:08Z parejkoj $
 
2
 
 
3
Frequently Asked Questions
 
4
 
 
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>.
 
9
 
 
10
======================================================================
 
11
 
 
12
Q1:
 
13
 
 
14
When running the following script
 
15
 
 
16
------------------------------------------------
 
17
#! /usr/bin/python2
 
18
 
 
19
import Gnuplot, Gnuplot.funcutils
 
20
from numpy import *
 
21
 
 
22
g = Gnuplot.Gnuplot()
 
23
g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]])
 
24
------------------------------------------------
 
25
 
 
26
I get the error
 
27
 
 
28
    gnuplot> plot  '/tmp/@24463.2'
 
29
                   ^
 
30
             can't read data file "/tmp/@24463.2"
 
31
             line 0: (No such file or directory)
 
32
 
 
33
However, the same commands work fine if I type them into the
 
34
interpreter!  What's wrong?
 
35
 
 
36
A1:
 
37
 
 
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
 
45
collected.)
 
46
 
 
47
To prevent this problem, there are several possibilities:
 
48
 
 
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.
 
52
 
 
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
 
58
   away.
 
59
 
 
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.,
 
67
 
 
68
       data = Gnuplot.Data([[0,1.1], [1,5.8], [2,3.3], [3,4.2]])
 
69
       g.plot(data)
 
70
       # ... do something guaranteed to last a couple seconds
 
71
       del data # temporary file is deleted at this moment
 
72
 
 
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
 
78
   to python, etc.
 
79
 
 
80
======================================================================
 
81
 
 
82
Q2:
 
83
 
 
84
Does Gnuplot.py work under Jython/Java?
 
85
 
 
86
A2:
 
87
 
 
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
 
90
seems to work.
 
91
 
 
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!
 
97
 
 
98
======================================================================
 
99
 
 
100
Q3:
 
101
 
 
102
[from Tate Wilson]
 
103
 
 
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?
 
108
 
 
109
A3:
 
110
 
 
111
I don't know.  But the same user later reported what worked for him:
 
112
 
 
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.
 
122
 
 
123
======================================================================
 
124
 
 
125
Q4:
 
126
 
 
127
I am using Windows and I get an error like
 
128
 
 
129
> Traceback (most recent call last):
 
130
> [...]
 
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
 
135
 
 
136
What is the problem?
 
137
 
 
138
A4:
 
139
 
 
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
 
146
to the executable.
 
147