1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
"http://www.w3.org/TR/html40/loose.dtd">
7
<title>Class: PlotItem</title>
10
<body bgcolor="#ffffff">
12
<p><i><a href="../../index.html">Table of Contents</a></i></p>
14
<table border="0" cellpadding="5" cellspacing="0" width="100%">
20
bgcolor="#88bbee"><font color="#000000">Class: PlotItem</font>
24
align="right"><font color="#000000">Gnuplot/PlotItems.py</font>
30
<h3>Plotitem represents an item that can be plotted by gnuplot.</h3>
31
<p> For the finest control over the output, you can create <code>PlotItems</code>
32
yourself with additional keyword options, or derive new classes
33
from <code>PlotItem</code>.</p>
34
<p> The handling of options is complicated by the attempt to allow
35
options and their setting mechanism to be inherited conveniently.
36
Note first that there are some options that can only be set in the
37
constructor then never modified, and others that can be set in the
38
constructor and/or modified using the <code>set_option()</code> member
39
function. The former are always processed within <code>__init__</code>. The
40
latter are always processed within <code>set_option</code>, which is called
41
by the constructor.</p>
42
<p> <code>set_option</code> is driven by a class-wide dictionary called
43
<code>_option_list</code>, which is a mapping <code>{ <option> : <setter> }</code> from
44
option name to the function object used to set or change the
45
option. <setter> is a function object that takes two parameters:
46
<code>self</code> (the <code>PlotItem</code> instance) and the new value requested for
47
the option. If <setter> is <code>None</code>, then the option is not allowed
48
to be changed after construction and an exception is raised.</p>
49
<p> Any <code>PlotItem</code> that needs to add options can add to this
50
dictionary within its class definition. Follow one of the
51
examples in this file. Alternatively it could override the
52
<code>set_option</code> member function if it needs to do wilder things.</p>
55
<dt> <code>_basecommand</code></dt>
56
<dd>a string holding the elementary argument that
57
must be passed to gnuplot's `plot' command for this item;
58
e.g., <code>sin(x)</code> or <code>"filename.dat"</code>.</dd>
59
<dt> <code>_options</code></dt>
60
<dd>a dictionary of (<option>,<string>) tuples
61
corresponding to the plot options that have been set for
62
this instance of the PlotItem. <option> is the option as
63
specified by the user; <string> is the string that needs to
64
be set in the command line to set that option (or None if no
65
string is needed). Example:
67
{'title' : ('Data', 'title "Data"'),
68
'with' : ('linespoints', 'with linespoints')}
72
<table border="0" cellpadding="5" cellspacing="0" width="100%">
81
<font color="#000000">
82
<a name="Methods">Methods</a>
90
<font color="#000000"> </font>
96
<a href="#__init__">__init__</a><br>
97
<a href="#clear_option">clear_option</a><br>
98
<a href="#command">command</a><br>
99
<a href="#get_base_command_string">get_base_command_string</a><br>
100
<a href="#get_command_option_string">get_command_option_string</a><br>
101
<a href="#get_option">get_option</a><br>
102
<a href="#pipein">pipein</a><br>
103
<a href="#set_option">set_option</a><br>
104
<a href="#set_string_option">set_string_option</a><br>
108
<th bgcolor="#99ccff"
114
<font color="#000000">
115
<a name="__init__"></a>
118
<th bgcolor="#99ccff"
123
<font color="#000000">__init__ </font>
128
<font color="#000088"><pre>
129
__init__ ( self, **keyw )
133
<h3>Construct a <code>PlotItem</code>.</h3>
134
<h4> Keyword options:</h4>
136
<dt> <code>with=<string></code></dt>
137
<dd>choose how item will be plotted, e.g.,
138
with=<code>points 3 3</code>.</dd>
139
<dt> <code>title=<string></code></dt>
140
<dd>set the title to be associated with the item
141
in the plot legend.</dd>
142
<dt> <code>title=None</code></dt>
143
<dd>choose <code>notitle</code> option (omit item from legend).</dd>
145
<p> Note that omitting the title option is different than setting
146
'title=None'; the former chooses gnuplot's default whereas the
147
latter chooses <code>notitle</code>.</p>
150
<th bgcolor="#99ccff"
156
<font color="#000000">
157
<a name="clear_option"></a>
160
<th bgcolor="#99ccff"
165
<font color="#000000">clear_option </font>
170
<font color="#000088"><pre>
171
clear_option ( self, name )
175
<p>Clear (unset) a plot option. No error if option was not set.</p>
178
<th bgcolor="#99ccff"
184
<font color="#000000">
185
<a name="command"></a>
188
<th bgcolor="#99ccff"
193
<font color="#000000">command </font>
198
<font color="#000088"><pre>
203
<h3>Build the plot command to be sent to gnuplot.</h3>
204
<p> Build and return the plot command, with options, necessary to
205
display this item. If anything else needs to be done once per
206
plot, it can be done here too.</p>
209
<th bgcolor="#99ccff"
215
<font color="#000000">
216
<a name="get_base_command_string"></a>
219
<th bgcolor="#99ccff"
224
<font color="#000000">get_base_command_string </font>
229
<font color="#000088"><pre>
230
get_base_command_string ( self )
234
<table border="0" cellpadding="5" cellspacing="0" width="100%">
237
<th bgcolor="#99ccff"
243
<font color="#000000">
244
<a name="Exceptions">Exceptions</a>
247
<th bgcolor="#99ccff"
252
<font color="#000000"> </font>
258
NotImplementedError()<br>
264
<th bgcolor="#99ccff"
270
<font color="#000000">
271
<a name="get_command_option_string"></a>
274
<th bgcolor="#99ccff"
279
<font color="#000000">get_command_option_string </font>
284
<font color="#000088"><pre>
285
get_command_option_string ( self )
291
<th bgcolor="#99ccff"
297
<font color="#000000">
298
<a name="get_option"></a>
301
<th bgcolor="#99ccff"
306
<font color="#000000">get_option </font>
311
<font color="#000088"><pre>
312
get_option ( self, name )
316
<p>Return the setting of an option. May be overridden.</p>
317
<table border="0" cellpadding="5" cellspacing="0" width="100%">
320
<th bgcolor="#99ccff"
326
<font color="#000000">
327
<a name="Exceptions">Exceptions</a>
330
<th bgcolor="#99ccff"
335
<font color="#000000"> </font>
341
KeyError( 'option %s is not set!' % name )<br>
347
<th bgcolor="#99ccff"
353
<font color="#000000">
354
<a name="pipein"></a>
357
<th bgcolor="#99ccff"
362
<font color="#000000">pipein </font>
367
<font color="#000088"><pre>
372
<h3>Pipe necessary inline data to gnuplot.</h3>
373
<p> If the plot command requires data to be put on stdin (i.e.,
374
<code>plot "-"</code>), this method should put that data there. Can be
375
overridden in derived classes.</p>
378
<th bgcolor="#99ccff"
384
<font color="#000000">
385
<a name="set_option"></a>
388
<th bgcolor="#99ccff"
393
<font color="#000000">set_option </font>
398
<font color="#000088"><pre>
399
set_option ( self, **keyw )
403
<h3>Set or change a plot option for this PlotItem.</h3>
404
<p> See documentation for <code>__init__</code> for information about allowed
405
options. This function can be overridden by derived classes
406
to allow additional options, in which case those options will
407
also be allowed by <code>__init__</code> for the derived class. However,
408
it is easier to define a new <code>_option_list</code> variable for the
410
<table border="0" cellpadding="5" cellspacing="0" width="100%">
413
<th bgcolor="#99ccff"
419
<font color="#000000">
420
<a name="Exceptions">Exceptions</a>
423
<th bgcolor="#99ccff"
428
<font color="#000000"> </font>
434
Errors.OptionError( 'Cannot modify %s option after construction!', option )<br>
435
Errors.OptionError('%s=%s' %( option, value ) )<br>
441
<th bgcolor="#99ccff"
447
<font color="#000000">
448
<a name="set_string_option"></a>
451
<th bgcolor="#99ccff"
456
<font color="#000000">set_string_option </font>
461
<font color="#000088"><pre>
472
<p>Set an option that takes a string value.</p>
483
<p><i><a href="../../index.html">Table of Contents</a></i></p>
485
<font size="-2"><i>This document was automatically generated
486
on Sun Oct 19 17:10:22 2003 by
487
<a href="http://happydoc.sourceforge.net">HappyDoc</a> version
b'\\ No newline at end of file'