File: PlotItems.py_PlotItem.html

package info (click to toggle)
python-gnuplot 1.5-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 764 kB
  • ctags: 554
  • sloc: python: 1,314; makefile: 45; sh: 22
file content (411 lines) | stat: -rw-r--r-- 12,190 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<html>

        <head>
        <title>Class: PlotItem</title>
        </head>

        <body bgcolor="#ffffff">

        <p><i><a href="../index.html">Table of Contents</a></i></p>
        
        <table border="0" cellpadding="5" cellspacing="0" width="100%">
        <tr bgcolor="#88bbee">
            <th rowspan="2"
                valign="top"
                align="left"
                width="10%"><font color="#000000">Class: PlotItem</font>
            </th>
            <th align="right"><font color="#000000">Gnuplot/PlotItems.py</font></th>
        </tr>
        <tr>
        <td>
        <dl><dt><p><strong>Plotitem represents an item that can be plotted by gnuplot.</strong><p>
</dt><dd><p>    For the finest control over the output, you can create <code>PlotItems</code>
    yourself with additional keyword options, or derive new classes
    from <code>PlotItem</code>.</p>

<p>    The handling of options is complicated by the attempt to allow
    options and their setting mechanism to be inherited conveniently.
    Note first that there are some options that can only be set in the
    constructor then never modified, and others that can be set in the
    constructor and/or modified using the <code>set_option()</code> member
    function.  The former are always processed within <code>__init__</code>.  The
    latter are always processed within <code>set_option</code>, which is called
    by the constructor.</p>

<p>    <code>set_option</code> is driven by a class-wide dictionary called
    <code>_option_list</code>, which is a mapping <code>{ <option> : <setter> }</code> from
    option name to the function object used to set or change the
    option.  <setter> is a function object that takes two parameters:
    <code>self</code> (the <code>PlotItem</code> instance) and the new value requested for
    the option.  If <setter> is <code>None</code>, then the option is not allowed
    to be changed after construction and an exception is raised.</p>

<p>    Any <code>PlotItem</code> that needs to add options can add to this
    dictionary within its class definition.  Follow one of the
    examples in this file.  Alternatively it could override the
    <code>set_option</code> member function if it needs to do wilder things.</p>

<p>    Members:</p>
<dl><dt>      <code>_basecommand</code></dt><dd><p>a string holding the elementary argument that
          must be passed to gnuplot's `plot' command for this item;
          e.g., <code>sin(x)</code> or <code>"filename.dat"</code>.</p>

</dd>
<dt>      <code>_options</code></dt><dd><p>a dictionary of (<option>,<string>) tuples
          corresponding to the plot options that have been set for
          this instance of the PlotItem.  <option> is the option as
          specified by the user; <string> is the string that needs to
          be set in the command line to set that option (or None if no
          string is needed).  Example::</p>
<p>              {'title' : (<code>Data</code>, <code>title "Data"</code>),
               <code>with</code> : (<code>linespoints</code>, <code>with linespoints</code>)}</p>


</dd></dl>


</dd></dl>
        
        <table border="0" cellpadding="5" cellspacing="0" width="100%%">
        
        <tr>
            <th bgcolor="#99ccff"
                rowspan="2"
                valign="top"
                align="left"
                width="20%"
                >
                <font color="#000000">
                  <a name="Methods">Methods</a>&nbsp;
                </font>
            </th>
            <th bgcolor="#99ccff"
                valign="top"
                align="left"
                >
                <font color="#000000">&nbsp;</font>
            </th>
        </tr>
        <tr>
        <td>
        
<a href="#__init__">__init__</a><br>
<a href="#clear_option">clear_option</a><br>
<a href="#command">command</a><br>
<a href="#get_option">get_option</a><br>
<a href="#pipein">pipein</a><br>
<a href="#set_option">set_option</a><br>
<a href="#set_string_option">set_string_option</a><br>


        <tr>
            <th bgcolor="#99ccff"
                rowspan="2"
                valign="top"
                align="left"
                width="20%"
                >
                <font color="#000000">
                  <a name="__init__"></a>&nbsp;
                </font>
            </th>
            <th bgcolor="#99ccff"
                valign="top"
                align="left"
                >
                <font color="#000000">__init__&nbsp;</font>
            </th>
        </tr>
        <tr>
        <td>
        <pre>
__init__ (
        self,
        basecommand,
        **keyw,
        )

</pre><dl><dt><p><strong>Construct a <code>PlotItem</code>.</strong><p>
</dt><dd><p>        Keyword options:</p>
<dl><dt>          <code>with=<string></code></dt><dd><p>choose how item will be plotted, e.g.,
              with='points 3 3'.</p>

</dd>
<dt>          <code>title=<string></code></dt><dd><p>set the title to be associated with the item
              in the plot legend.</p>

</dd>
<dt>          <code>title=None</code></dt><dd><p>choose <code>notitle</code> option (omit item from legend).</p>

</dd></dl>

<p>        Note that omitting the title option is different than setting
        <code>title=None</code>; the former chooses gnuplot's default whereas the
        latter chooses <code>notitle</code>.</p>


</dd></dl>

        <tr>
            <th bgcolor="#99ccff"
                rowspan="2"
                valign="top"
                align="left"
                width="20%"
                >
                <font color="#000000">
                  <a name="clear_option"></a>&nbsp;
                </font>
            </th>
            <th bgcolor="#99ccff"
                valign="top"
                align="left"
                >
                <font color="#000000">clear_option&nbsp;</font>
            </th>
        </tr>
        <tr>
        <td>
        <pre>
clear_option ( self,  name )

</pre><p>Clear (unset) a plot option.  No error if option was not set.</p>


        <tr>
            <th bgcolor="#99ccff"
                rowspan="2"
                valign="top"
                align="left"
                width="20%"
                >
                <font color="#000000">
                  <a name="command"></a>&nbsp;
                </font>
            </th>
            <th bgcolor="#99ccff"
                valign="top"
                align="left"
                >
                <font color="#000000">command&nbsp;</font>
            </th>
        </tr>
        <tr>
        <td>
        <pre>
command ( self )

</pre><dl><dt><p><strong>Build the plot command to be sent to gnuplot.</strong><p>
</dt><dd><p>        Build and return the plot command, with options, necessary to
        display this item.</p>


</dd></dl>

        <tr>
            <th bgcolor="#99ccff"
                rowspan="2"
                valign="top"
                align="left"
                width="20%"
                >
                <font color="#000000">
                  <a name="get_option"></a>&nbsp;
                </font>
            </th>
            <th bgcolor="#99ccff"
                valign="top"
                align="left"
                >
                <font color="#000000">get_option&nbsp;</font>
            </th>
        </tr>
        <tr>
        <td>
        <pre>
get_option ( self,  name )

</pre><p>Return the setting of an option.  May be overridden.</p>

        
        <table border="0" cellpadding="5" cellspacing="0" width="100%%">
        
        <tr>
            <th bgcolor="#99ccff"
                rowspan="2"
                valign="top"
                align="left"
                width="20%"
                >
                <font color="#000000">
                  <a name="Exceptions">Exceptions</a>&nbsp;
                </font>
            </th>
            <th bgcolor="#99ccff"
                valign="top"
                align="left"
                >
                <font color="#000000">&nbsp;</font>
            </th>
        </tr>
        <tr>
        <td>
        
<pre>
KeyError( 'option %s is not set!' % name )

</pre>

        </td>
        </tr>
        </table>
        
        <tr>
            <th bgcolor="#99ccff"
                rowspan="2"
                valign="top"
                align="left"
                width="20%"
                >
                <font color="#000000">
                  <a name="pipein"></a>&nbsp;
                </font>
            </th>
            <th bgcolor="#99ccff"
                valign="top"
                align="left"
                >
                <font color="#000000">pipein&nbsp;</font>
            </th>
        </tr>
        <tr>
        <td>
        <pre>
pipein ( self,  f )

</pre><dl><dt><p><strong>Pipe necessary inline data to gnuplot.</strong><p>
</dt><dd><p>        If the plot command requires data to be put on stdin (i.e.,
        <code>plot "-"</code>), this method should put that data there.  Can be
        overridden in derived classes.</p>


</dd></dl>

        <tr>
            <th bgcolor="#99ccff"
                rowspan="2"
                valign="top"
                align="left"
                width="20%"
                >
                <font color="#000000">
                  <a name="set_option"></a>&nbsp;
                </font>
            </th>
            <th bgcolor="#99ccff"
                valign="top"
                align="left"
                >
                <font color="#000000">set_option&nbsp;</font>
            </th>
        </tr>
        <tr>
        <td>
        <pre>
set_option ( self,  **keyw )

</pre><dl><dt><p><strong>Set or change a plot option for this PlotItem.</strong><p>
</dt><dd><p>        See documentation for <code>__init__</code> for information about allowed
        options.  This function can be overridden by derived classes
        to allow additional options, in which case those options will
        also be allowed by <code>__init__</code> for the derived class.  However,
        it is easier to define a new <code>_option_list</code> variable for the
        derived class.</p>


</dd></dl>
        
        <table border="0" cellpadding="5" cellspacing="0" width="100%%">
        
        <tr>
            <th bgcolor="#99ccff"
                rowspan="2"
                valign="top"
                align="left"
                width="20%"
                >
                <font color="#000000">
                  <a name="Exceptions">Exceptions</a>&nbsp;
                </font>
            </th>
            <th bgcolor="#99ccff"
                valign="top"
                align="left"
                >
                <font color="#000000">&nbsp;</font>
            </th>
        </tr>
        <tr>
        <td>
        
<pre>
OptionException( 'Cannot modify %s option after ' 'construction!', option )
OptionException('%s=%s' %( option, value ) )

</pre>

        </td>
        </tr>
        </table>
        
        <tr>
            <th bgcolor="#99ccff"
                rowspan="2"
                valign="top"
                align="left"
                width="20%"
                >
                <font color="#000000">
                  <a name="set_string_option"></a>&nbsp;
                </font>
            </th>
            <th bgcolor="#99ccff"
                valign="top"
                align="left"
                >
                <font color="#000000">set_string_option&nbsp;</font>
            </th>
        </tr>
        <tr>
        <td>
        <pre>
set_string_option (
        self,
        option,
        value,
        default,
        fmt,
        )

</pre><p>Set an option that takes a string value.</p>

</td></tr>
        </td>
        </tr>
        </table>
        
        </td>
        </tr>
        </table>

        <hr>

        <p><i><a href="../index.html">Table of Contents</a></i></p>

        <i>This document was automatically generated on Fri Jan 26 14:06:11 2001
        by <a href="http://happydoc.sourceforge.net">HappyDoc</a> version r0_9_2</i>

        </body>
        </html>