4
<title>Class: Gnuplot</title>
7
<body bgcolor="#ffffff">
9
<p><i><a href="index.html">Table of Contents</a></i></p>
11
<table border="0" cellpadding="5" cellspacing="0" width="100%">
12
<tr bgcolor="#88bbee">
16
width="10%"><font color="#000000">Class: Gnuplot</font>
18
<th align="right"><font color="#000000">./_Gnuplot.py</font></th>
22
<dl><dt><p><strong>Interface to a gnuplot program.</strong><p>
23
</dt><dd><p> A Gnuplot represents a higher-level interface to a gnuplot
24
program. It can plot 'PlotItem's, which represent each thing to
25
be plotted on the current graph. It keeps a reference to each of
26
the <code>PlotItems</code> used in the current plot, so that they (and their
27
associated temporary files) are not deleted prematurely.</p>
30
<dl><dt> <code>itemlist</code></dt><dd><p>a list of the PlotItems that are associated with
31
the current plot. These are deleted whenever a new plot
32
command is issued via the <code>plot</code> method.</p>
35
<dt> <code>plotcmd</code></dt><dd><p><code>plot</code> or <code>splot</code>, depending on what was the last
41
<dl><dt> <code>__init__</code></dt><dd><p>if a filename argument is specified, the
42
commands will be written to that file instead of being
46
<dt> <code>plot</code></dt><dd><p>clear the old plot and old <code>PlotItems</code>, then plot
47
the arguments in a fresh plot command. Arguments can be:
48
a <code>PlotItem</code>, which is plotted along with its internal
49
options; a string, which is plotted as a <code>Func</code>; or
50
anything else, which is plotted as a <code>Data</code>.</p>
53
<dt> <code>splot</code></dt><dd><p>like <code>plot</code>, except for 3-d plots.</p>
56
<dt> <code>hardcopy</code></dt><dd><p>replot the plot to a postscript file (if
57
filename argument is specified) or pipe it to the printer
58
as postscript othewise. If the option <code>color</code> is set to
59
true, then output color postscript.</p>
62
<dt> <code>replot</code></dt><dd><p>replot the old items, adding any arguments as
63
additional items as in the plot method.</p>
66
<dt> <code>refresh</code></dt><dd><p>issue (or reissue) the plot command using the
67
current <code>PlotItems</code>.</p>
70
<dt> <code>__call__</code></dt><dd><p>pass an arbitrary string to the gnuplot process,
71
followed by a newline.</p>
74
<dt> <code>xlabel</code>, <code>ylabel</code>, <code>title</code></dt><dd><p>set corresponding plot
78
<dt> <code>interact</code></dt><dd><p>read lines from stdin and send them, one by one,
79
to the gnuplot interpreter. Basically you can type
80
commands directly to the gnuplot command processor.</p>
83
<dt> <code>load</code></dt><dd><p>load a file (using the gnuplot <code>load</code> command).</p>
86
<dt> <code>save</code></dt><dd><p>save gnuplot commands to a file (using gnuplot
87
<code>save</code> command) If any of the 'PlotItem's is a temporary
88
file, it will be deleted at the usual time and the save
89
file will be pretty useless :-).</p>
92
<dt> <code>clear</code></dt><dd><p>clear the plot window (but not the itemlist).</p>
95
<dt> <code>reset</code></dt><dd><p>reset all gnuplot settings to their defaults and
96
clear the current itemlist.</p>
99
<dt> <code>set_string</code></dt><dd><p>set or unset a gnuplot option whose value is a
103
<dt> <code>_clear_queue</code></dt><dd><p>clear the current <code>PlotItem</code> list.</p>
106
<dt> <code>_add_to_queue</code></dt><dd><p>add the specified items to the current
107
<code>PlotItem</code> list.</p>
114
<table border="0" cellpadding="5" cellspacing="0" width="100%%">
117
<th bgcolor="#99ccff"
123
<font color="#000000">
124
<a name="Methods">Methods</a>
127
<th bgcolor="#99ccff"
131
<font color="#000000"> </font>
137
<table border="0" cellspacing="2" cellpadding="2" width="100%">
138
<tr><td align="LEFT" valign="TOP">
139
<a href="#__call__">__call__</a><br>
140
<a href="#__init__">__init__</a><br>
141
<a href="#_add_to_queue">_add_to_queue</a><br>
142
<a href="#_clear_queue">_clear_queue</a><br>
143
<a href="#clear">clear</a><br>
144
<a href="#hardcopy">hardcopy</a><br>
145
<a href="#interact">interact</a><br>
146
<a href="#load">load</a><br>
147
<a href="#plot">plot</a><br>
148
<a href="#refresh">refresh</a><br>
150
<td align="LEFT" valign="TOP">
151
<a href="#replot">replot</a><br>
152
<a href="#reset">reset</a><br>
153
<a href="#save">save</a><br>
154
<a href="#set">set</a><br>
155
<a href="#set_boolean">set_boolean</a><br>
156
<a href="#set_range">set_range</a><br>
157
<a href="#set_string">set_string</a><br>
158
<a href="#splot">splot</a><br>
159
<a href="#title">title</a><br>
160
<a href="#xlabel">xlabel</a><br>
162
<td align="LEFT" valign="TOP">
163
<a href="#ylabel">ylabel</a><br>
169
<th bgcolor="#99ccff"
175
<font color="#000000">
176
<a name="__call__"></a>
179
<th bgcolor="#99ccff"
183
<font color="#000000">__call__ </font>
191
</pre><dl><dt><p><strong>Send a command string to gnuplot.</strong><p>
192
</dt><dd><p> Send the string s as a command to gnuplot, followed by a
193
newline. All communication with the gnuplot process (except
194
for inline data) is through this method.</p>
200
<th bgcolor="#99ccff"
206
<font color="#000000">
207
<a name="__init__"></a>
210
<th bgcolor="#99ccff"
214
<font color="#000000">__init__ </font>
227
</pre><dl><dt><p><strong>Create a Gnuplot object.</strong><p>
228
</dt><dd><p> Create a <code>Gnuplot</code> object. By default, this starts a gnuplot
229
process and prepares to write commands to it.</p>
231
<p> Keyword arguments:</p>
232
<dl><dt> <code>filename=<string></code></dt><dd><p>if a filename is specified, the
233
commands are instead written to that file (e.g., for
234
later use using <code>load</code>).</p>
237
<dt> <code>persist=1</code></dt><dd><p>start gnuplot with the <code>-persist</code> option
238
(which creates a new plot window for each plot command).
239
(This option is not available on older versions of
243
<dt> <code>debug=1</code></dt><dd><p>echo the gnuplot commands to stderr as well as
244
sending them to gnuplot.</p>
252
<th bgcolor="#99ccff"
258
<font color="#000000">
259
<a name="_add_to_queue"></a>
262
<th bgcolor="#99ccff"
266
<font color="#000000">_add_to_queue </font>
272
_add_to_queue ( self, items )
274
</pre><dl><dt><p><strong>Add a list of items to the itemlist (but don't plot them).</strong><p>
275
</dt><dd><p> <code>items</code> is a sequence of items, each of which should be a
276
<code>PlotItem</code> of some kind, a string (interpreted as a function
277
string for gnuplot to evaluate), or a Numeric array (or
278
something that can be converted to a Numeric array).</p>
284
<th bgcolor="#99ccff"
290
<font color="#000000">
291
<a name="_clear_queue"></a>
294
<th bgcolor="#99ccff"
298
<font color="#000000">_clear_queue </font>
304
_clear_queue ( self )
306
</pre><p>Clear the <code>PlotItems</code> from the queue.</p>
310
<th bgcolor="#99ccff"
316
<font color="#000000">
317
<a name="clear"></a>
320
<th bgcolor="#99ccff"
324
<font color="#000000">clear </font>
332
</pre><p>Clear the plot window (without affecting the current itemlist).</p>
336
<th bgcolor="#99ccff"
342
<font color="#000000">
343
<a name="hardcopy"></a>
346
<th bgcolor="#99ccff"
350
<font color="#000000">hardcopy </font>
369
</pre><dl><dt><p><strong>Create a hardcopy of the current plot.</strong><p>
370
</dt><dd><p> Create a postscript hardcopy of the current plot to the
371
default printer (if configured) or to the specified filename.</p>
373
<p> Note that gnuplot remembers the postscript suboptions across
374
terminal changes. Therefore if you set, for example, color=1
375
for one hardcopy then the next hardcopy will also be color
376
unless you explicitly choose color=0. Alternately you can
377
force all of the options to their defaults by setting
378
mode='default'. I consider this to be a bug in gnuplot.</p>
380
<p> Keyword arguments:</p>
381
<dl><dt> <code>filename=<string></code></dt><dd><p>if a filename is specified, save the
382
output in that file; otherwise print it immediately
383
using the <code>default_lpr</code> configuration option.</p>
386
<dt> <code>mode=<string></code></dt><dd><p>set the postscript submode (<code>landscape</code>,
387
<code>portrait</code>, <code>eps</code>, or <code>default</code>). The default is
388
to leave this option unspecified.</p>
391
<dt> <code>eps=<bool></code></dt><dd><p>shorthand for <code>mode="eps"</code>; asks gnuplot to
392
generate encapsulated postscript.</p>
395
<dt> <code>enhanced=<bool></code></dt><dd><p>if set (the default), then generate
396
enhanced postscript, which allows extra features like
397
font-switching, superscripts, and subscripts in axis
398
labels. (Some old gnuplot versions do not support
399
enhanced postscript; if this is the case set
400
gp.GnuplotOpts.prefer_enhanced_postscript=None.)</p>
403
<dt> <code>color=<bool></code></dt><dd><p>if set, create a plot with color. Default
404
is to leave this option unchanged.</p>
407
<dt> <code>solid=<bool></code></dt><dd><p>if set, force lines to be solid (i.e., not
411
<dt> <code>duplexing=<string></code></dt><dd><p>set duplexing option (<code>defaultplex</code>,
412
<code>simplex</code>, or <code>duplex</code>). Only request double-sided
413
printing if your printer can handle it. Actually this
414
option is probably meaningless since hardcopy() can only
415
print a single plot at a time.</p>
418
<dt> <code>fontname=<string></code></dt><dd><p>set the default font to <string>,
419
which must be a valid postscript font. The default is
420
to leave this option unspecified.</p>
423
<dt> <code>fontsize=<double></code></dt><dd><p>set the default font size, in
424
postscript points.</p>
428
<p> Note that this command will return immediately even though it
429
might take gnuplot a while to actually finish working. Be
430
sure to pause briefly before issuing another command that
431
might cause the temporary files to be deleted.</p>
437
<th bgcolor="#99ccff"
443
<font color="#000000">
444
<a name="interact"></a>
447
<th bgcolor="#99ccff"
451
<font color="#000000">interact </font>
459
</pre><dl><dt><p><strong>Allow user to type arbitrary commands to gnuplot.</strong><p>
460
</dt><dd><p> Read stdin, line by line, and send each line as a command to
461
gnuplot. End by typing C-d.</p>
467
<th bgcolor="#99ccff"
473
<font color="#000000">
474
<a name="load"></a>
477
<th bgcolor="#99ccff"
481
<font color="#000000">load </font>
487
load ( self, filename )
489
</pre><p>Load a file using gnuplot's <code>load</code> command.</p>
493
<th bgcolor="#99ccff"
499
<font color="#000000">
500
<a name="plot"></a>
503
<th bgcolor="#99ccff"
507
<font color="#000000">plot </font>
519
</pre><dl><dt><p><strong>Draw a new plot.</strong><p>
520
</dt><dd><p> Clear the current plot and create a new 2-d plot containing
521
the specified items. Each arguments should be of the
524
<dl><dt> <code>PlotItem</code> (e.g., <code>Data</code>, <code>File</code>, <code>Func</code>)</dt><dd><p>This is the most
525
flexible way to call plot because the PlotItems can
526
contain suboptions. Moreover, PlotItems can be saved to
527
variables so that their lifetime is longer than one plot
528
command; thus they can be replotted with minimal overhead.</p>
531
<dt> <code>string</code> (e.g., <code>sin(x)</code>)</dt><dd><p>The string is interpreted as
532
<code>Func(string)</code> (a function that is computed by gnuplot).</p>
535
<dt> Anything else</dt><dd><p>The object, which should be convertible to an
536
array, is passed to the <code>Data</code> constructor, and thus
537
plotted as data. If the conversion fails, an exception is
545
<th bgcolor="#99ccff"
551
<font color="#000000">
552
<a name="refresh"></a>
555
<th bgcolor="#99ccff"
559
<font color="#000000">refresh </font>
567
</pre><dl><dt><p><strong>Refresh the plot, using the current 'PlotItem's.</strong><p>
568
</dt><dd><p> Refresh the current plot by reissuing the gnuplot plot command
569
corresponding to the current itemlist.</p>
575
<th bgcolor="#99ccff"
581
<font color="#000000">
582
<a name="replot"></a>
585
<th bgcolor="#99ccff"
589
<font color="#000000">replot </font>
601
</pre><dl><dt><p><strong>Replot the data, possibly adding new 'PlotItem's.</strong><p>
602
</dt><dd><p> Replot the existing graph, using the items in the current
603
itemlist. If arguments are specified, they are interpreted as
604
additional items to be plotted alongside the existing items on
605
the same graph. See <code>plot</code> for details.</p>
611
<th bgcolor="#99ccff"
617
<font color="#000000">
618
<a name="reset"></a>
621
<th bgcolor="#99ccff"
625
<font color="#000000">reset </font>
633
</pre><p>Reset all gnuplot settings to their defaults and clear itemlist.</p>
637
<th bgcolor="#99ccff"
643
<font color="#000000">
644
<a name="save"></a>
647
<th bgcolor="#99ccff"
651
<font color="#000000">save </font>
657
save ( self, filename )
659
</pre><p>Save the current plot commands using gnuplot's <code>save</code> command.</p>
663
<th bgcolor="#99ccff"
669
<font color="#000000">
670
<a name="set"></a>
673
<th bgcolor="#99ccff"
677
<font color="#000000">set </font>
685
</pre><p>Set one or more settings at once from keyword arguments.
686
The allowed settings and their treatments are determined from
687
the optiontypes mapping.</p>
690
<table border="0" cellpadding="5" cellspacing="0" width="100%%">
693
<th bgcolor="#99ccff"
699
<font color="#000000">
700
<a name="Exceptions">Exceptions</a>
703
<th bgcolor="#99ccff"
707
<font color="#000000"> </font>
714
'option %s is not supported'
723
<th bgcolor="#99ccff"
729
<font color="#000000">
730
<a name="set_boolean"></a>
733
<th bgcolor="#99ccff"
737
<font color="#000000">set_boolean </font>
749
</pre><p>Set an on/off option. It is assumed that the way to turn
750
the option on is to type `set <option>' and to turn it off,
751
`set no<option>'.</p>
755
<th bgcolor="#99ccff"
761
<font color="#000000">
762
<a name="set_range"></a>
765
<th bgcolor="#99ccff"
769
<font color="#000000">set_range </font>
781
</pre><p>Set a range option (xrange, yrange, trange, urange, etc.).
782
The value can be a string (which is passed as-is, without
783
quotes) or a tuple (minrange,maxrange) of numbers or string
784
expressions recognized by gnuplot. If either range is None
785
then that range is passed as `*' (which means to
790
<th bgcolor="#99ccff"
796
<font color="#000000">
797
<a name="set_string"></a>
800
<th bgcolor="#99ccff"
804
<font color="#000000">set_string </font>
816
</pre><p>Set a string option, or if s is omitted, unset the option.</p>
820
<th bgcolor="#99ccff"
826
<font color="#000000">
827
<a name="splot"></a>
830
<th bgcolor="#99ccff"
834
<font color="#000000">splot </font>
846
</pre><dl><dt><p><strong>Draw a new three-dimensional plot.</strong><p>
847
</dt><dd><p> Clear the current plot and create a new 3-d plot containing
848
the specified items. Arguments can be of the following types:</p>
850
<dl><dt> <code>PlotItem</code> (e.g., <code>Data</code>, <code>File</code>, <code>Func</code>, <code>GridData</code> )</dt><dd><p>This
851
is the most flexible way to call plot because the
852
PlotItems can contain suboptions. Moreover, PlotItems can
853
be saved to variables so that their lifetime is longer
854
than one plot command--thus they can be replotted with
855
minimal overhead.</p>
858
<dt> <code>string</code> (e.g., <code>sin(x*y)</code>)</dt><dd><p>The string is interpreted as a
859
<code>Func()</code> (a function that is computed by gnuplot).</p>
862
<dt> Anything else</dt><dd><p>The object is converted to a Data() item, and
863
thus plotted as data. Note that each data point should
864
normally have at least three values associated with it
865
(i.e., x, y, and z). If the conversion fails, an
866
exception is raised.</p>
873
<th bgcolor="#99ccff"
879
<font color="#000000">
880
<a name="title"></a>
883
<th bgcolor="#99ccff"
887
<font color="#000000">title </font>
893
title ( self, s=None )
895
</pre><p>Set the plot's title.</p>
899
<th bgcolor="#99ccff"
905
<font color="#000000">
906
<a name="xlabel"></a>
909
<th bgcolor="#99ccff"
913
<font color="#000000">xlabel </font>
919
xlabel ( self, s=None )
921
</pre><p>Set the plot's xlabel.</p>
925
<th bgcolor="#99ccff"
931
<font color="#000000">
932
<a name="ylabel"></a>
935
<th bgcolor="#99ccff"
939
<font color="#000000">ylabel </font>
945
ylabel ( self, s=None )
947
</pre><p>Set the plot's ylabel.</p>
960
<p><i><a href="index.html">Table of Contents</a></i></p>
962
<i>This document was automatically generated on Fri Jan 26 13:13:18 2001
963
by <a href="http://happydoc.sourceforge.net">HappyDoc</a> version r0_9_2</i>
b'\\ No newline at end of file'