Trees | Index | Help |
|
---|
Package Gnuplot :: Module _Gnuplot :: Class Gnuplot |
|
PlotFactory
Interface to a gnuplot program. A Gnuplot represents a higher-level interface to a gnuplot program. It can plot 'PlotItem's, which represent each thing to be plotted on the current graph. It keeps a reference to each of the 'PlotItems' used in the current plot, so that they (and their associated temporary files) are not deleted prematurely. Members: 'itemlist' -- a list of the PlotItems that are associated with the current plot. These are deleted whenever a new plot command is issued via the 'plot' method. 'plotcmd' -- 'plot' or 'splot', depending on what was the last plot command. Methods: '__init__' -- if a filename argument is specified, the commands will be written to that file instead of being piped to gnuplot. 'plot' -- clear the old plot and old 'PlotItems', then plot the arguments in a fresh plot command. Arguments can be: a 'PlotItem', which is plotted along with its internal options; a string, which is plotted as a 'Func'; or anything else, which is plotted as a 'Data'. 'splot' -- like 'plot', except for 3-d plots. 'hardcopy' -- replot the plot to a postscript file (if filename argument is specified) or pipe it to the printer as postscript othewise. If the option 'color' is set to true, then output color postscript. 'replot' -- replot the old items, adding any arguments as additional items as in the plot method. 'refresh' -- issue (or reissue) the plot command using the current 'PlotItems'. '__call__' -- pass an arbitrary string to the gnuplot process, followed by a newline. 'xlabel', 'ylabel', 'title' -- set corresponding plot attribute. 'interact' -- read lines from stdin and send them, one by one, to the gnuplot interpreter. Basically you can type commands directly to the gnuplot command processor. 'load' -- load a file (using the gnuplot 'load' command). 'save' -- save gnuplot commands to a file (using gnuplot 'save' command) If any of the 'PlotItem's is a temporary file, it will be deleted at the usual time and the save file will be pretty useless :-). 'clear' -- clear the plot window (but not the itemlist). 'reset' -- reset all gnuplot settings to their defaults and clear the current itemlist. 'set_string' -- set or unset a gnuplot option whose value is a string. '_clear_queue' -- clear the current 'PlotItem' list. '_add_to_queue' -- add the specified items to the current 'PlotItem' list.
Method Summary | |
---|---|
Create a Gnuplot object. | |
Send a command string to gnuplot. | |
Add a list of items to the itemlist (but don't plot them). | |
Clear the 'PlotItems' from the queue. | |
Clear the plot window (without affecting the current itemlist). | |
Create a hardcopy of the current plot. | |
Allow user to type arbitrary commands to gnuplot. | |
Load a file using gnuplot's 'load' command. | |
Draw a new plot. | |
Refresh the plot, using the current 'PlotItem's. | |
Replot the data, possibly adding new 'PlotItem's. | |
Reset all gnuplot settings to their defaults and clear itemlist. | |
Save the current plot commands using gnuplot's 'save' command. | |
Set one or more settings at once from keyword arguments. | |
Set an on/off option. | |
Set or clear a label option, which can include an offset or font. | |
Set a range option (xrange, yrange, trange, urange, etc.). | |
Set a string option, or if s is omitted, unset the option. | |
Draw a new three-dimensional plot. | |
Set the plot's title. | |
Set the plot's xlabel. | |
Set the plot's ylabel. |
Class Variable Summary | |
---|---|
dict |
optiontypes = {'polar': 'boolean', 'yrange': 'range', 't...
|
Method Details |
---|
__init__(self,
filename=None,
persist=None,
debug=0)
|
__call__(self,
s)
|
_add_to_queue(self, items)Add a list of items to the itemlist (but don't plot them). 'items' is a sequence of items, each of which should be a 'PlotItem' of some kind, a string (interpreted as a function string for gnuplot to evaluate), or a Numeric array (or something that can be converted to a Numeric array). |
_clear_queue(self)Clear the 'PlotItems' from the queue. |
clear(self)Clear the plot window (without affecting the current itemlist). |
hardcopy(self, filename=None, terminal='postscript', **keyw)Create a hardcopy of the current plot. Create a postscript hardcopy of the current plot to the default printer (if configured) or to the specified filename. Note that gnuplot remembers the postscript suboptions across terminal changes. Therefore if you set, for example, color=1 for one hardcopy then the next hardcopy will also be color unless you explicitly choose color=0. Alternately you can force all of the options to their defaults by setting mode='default'. I consider this to be a bug in gnuplot. Keyword arguments: 'filename=<string>' -- if a filename is specified, save the output in that file; otherwise print it immediately using the 'default_lpr' configuration option. 'terminal=<string>' -- the type of gnuplot 'terminal' to use for the output (e.g., 'postscript', 'png', 'latex', etc). At the moment only 'postscript' is implemented. The rest of the keyword arguments depend on the terminal type. Keyword arguments for 'postscript' terminal: 'mode=<string>' -- set the postscript submode ('landscape', 'portrait', 'eps', or 'default'). The default is to leave this option unspecified. 'eps=<bool>' -- shorthand for 'mode="eps"'; asks gnuplot to generate encapsulated postscript. 'enhanced=<bool>' -- if set (the default), then generate enhanced postscript, which allows extra features like font-switching, superscripts, and subscripts in axis labels. (Some old gnuplot versions do not support enhanced postscript; if this is the case set gp.GnuplotOpts.prefer_enhanced_postscript=None.) 'color=<bool>' -- if set, create a plot with color. Default is to leave this option unchanged. 'solid=<bool>' -- if set, force lines to be solid (i.e., not dashed). 'duplexing=<string>' -- set duplexing option ('defaultplex', 'simplex', or 'duplex'). Only request double-sided printing if your printer can handle it. Actually this option is probably meaningless since hardcopy() can only print a single plot at a time. 'fontname=<string>' -- set the default font to <string>, which must be a valid postscript font. The default is to leave this option unspecified. 'fontsize=<double>' -- set the default font size, in postscript points. Note that this command will return immediately even though it might take gnuplot a while to actually finish working. Be sure to pause briefly before issuing another command that might cause the temporary files to be deleted. |
interact(self)Allow user to type arbitrary commands to gnuplot. Read stdin, line by line, and send each line as a command to gnuplot. End by typing C-d. |
load(self, filename)Load a file using gnuplot's 'load' command. |
plot(self, *items, **keyw)Draw a new plot. Clear the current plot and create a new 2-d plot containing the specified items. Each arguments should be of the following types: 'PlotItem' (e.g., 'Data', 'File', 'Func') -- This is the most flexible way to call plot because the PlotItems can contain suboptions. Moreover, PlotItems can be saved to variables so that their lifetime is longer than one plot command; thus they can be replotted with minimal overhead. 'string' (e.g., 'sin(x)') -- The string is interpreted as 'Func(string)' (a function that is computed by gnuplot). Anything else -- The object, which should be convertible to an array, is passed to the 'Data' constructor, and thus plotted as data. If the conversion fails, an exception is raised. |
refresh(self)Refresh the plot, using the current 'PlotItem's. Refresh the current plot by reissuing the gnuplot plot command corresponding to the current itemlist. |
replot(self, *items, **keyw)Replot the data, possibly adding new 'PlotItem's. Replot the existing graph, using the items in the current itemlist. If arguments are specified, they are interpreted as additional items to be plotted alongside the existing items on the same graph. See 'plot' for details. |
reset(self)Reset all gnuplot settings to their defaults and clear itemlist. |
save(self, filename)Save the current plot commands using gnuplot's 'save' command. |
set(self, **keyw)Set one or more settings at once from keyword arguments. The allowed settings and their treatments are determined from the optiontypes mapping. |
set_boolean(self, option, value)Set an on/off option. It is assumed that the way to turn the option on is to type `set <option>' and to turn it off, `set no<option>'. |
set_label(self, option, s=None, offset=None, font=None)Set or clear a label option, which can include an offset or font. If offset is specified, it should be a tuple of two integers or floats. If font is specified, it is appended to the command as a string in double quotes. Its interpretation is terminal-dependent; for example, for postscript it might be 'Helvetica,14' for 14 point Helvetica. |
set_range(self, option, value)Set a range option (xrange, yrange, trange, urange, etc.). The value can be a string (which is passed as-is, without quotes) or a tuple (minrange,maxrange) of numbers or string expressions recognized by gnuplot. If either range is None then that range is passed as `*' (which means to autoscale). |
set_string(self, option, s=None)Set a string option, or if s is omitted, unset the option. |
splot(self, *items, **keyw)Draw a new three-dimensional plot. Clear the current plot and create a new 3-d plot containing the specified items. Arguments can be of the following types: 'PlotItem' (e.g., 'Data', 'File', 'Func', 'GridData' ) -- This is the most flexible way to call plot because the PlotItems can contain suboptions. Moreover, PlotItems can be saved to variables so that their lifetime is longer than one plot command--thus they can be replotted with minimal overhead. 'string' (e.g., 'sin(x*y)') -- The string is interpreted as a 'Func()' (a function that is computed by gnuplot). Anything else -- The object is converted to a Data() item, and thus plotted as data. Note that each data point should normally have at least three values associated with it (i.e., x, y, and z). If the conversion fails, an exception is raised. |
title(self, s=None, offset=None, font=None)Set the plot's title. |
xlabel(self, s=None, offset=None, font=None)Set the plot's xlabel. |
ylabel(self, s=None, offset=None, font=None)Set the plot's ylabel. |
Class Variable Details |
---|
optiontypes
|
Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Tue Mar 22 13:16:54 2005 | http://epydoc.sf.net |