Plotitem represents an item that can be plotted by gnuplot.
For the finest control over the output, you can create PlotItems
yourself with additional keyword options, or derive new classes
from PlotItem .
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 set_option() member
function. The former are always processed within __init__ . The
latter are always processed within set_option , which is called
by the constructor.
set_option is driven by a class-wide dictionary called
_option_list , which is a mapping { <option> : <setter> } from
option name to the function object used to set or change the
option. <setter> is a function object that takes two parameters:
self (the PlotItem instance) and the new value requested for
the option. If <setter> is None , then the option is not allowed
to be changed after construction and an exception is raised.
Any PlotItem 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
set_option member function if it needs to do wilder things.
Members:
-
_basecommand
- a string holding the elementary argument that
must be passed to gnuplot's `plot' command for this item;
e.g.,
sin(x) or "filename.dat" .
-
_options
- 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:
{'title' : ('Data', 'title "Data"'),
'with' : ('linespoints', 'with linespoints')}
Methods
|
|
__init__
clear_option
command
get_base_command_string
get_command_option_string
get_option
pipein
set_option
set_string_option
|
|
__init__
|
__init__ ( self, **keyw )
Construct a PlotItem .
Keyword options:
-
with=<string>
- choose how item will be plotted, e.g.,
with=
points 3 3 .
-
title=<string>
- set the title to be associated with the item
in the plot legend.
-
title=None
- choose
notitle option (omit item from legend).
Note that omitting the title option is different than setting
'title=None'; the former chooses gnuplot's default whereas the
latter chooses notitle .
|
|
clear_option
|
clear_option ( self, name )
Clear (unset) a plot option. No error if option was not set.
|
|
command
|
command ( self )
Build the plot command to be sent to gnuplot.
Build and return the plot command, with options, necessary to
display this item. If anything else needs to be done once per
plot, it can be done here too.
|
|
get_base_command_string
|
get_base_command_string ( self )
|
|
get_command_option_string
|
get_command_option_string ( self )
|
|
get_option
|
get_option ( self, name )
Return the setting of an option. May be overridden.
Exceptions
|
|
KeyError( 'option %s is not set!' % name )
|
|
|
pipein
|
pipein ( self, f )
Pipe necessary inline data to gnuplot.
If the plot command requires data to be put on stdin (i.e.,
plot "-" ), this method should put that data there. Can be
overridden in derived classes.
|
|
set_option
|
set_option ( self, **keyw )
Set or change a plot option for this PlotItem.
See documentation for __init__ 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 __init__ for the derived class. However,
it is easier to define a new _option_list variable for the
derived class.
Exceptions
|
|
Errors.OptionError( 'Cannot modify %s option after construction!', option )
Errors.OptionError('%s=%s' %( option, value ) )
|
|
|
set_string_option
|
set_string_option (
self,
option,
value,
default,
fmt,
)
Set an option that takes a string value.
|
|