Known subclasses: yampex.plot.Plotter

I am an abstract base class with the option setting methods of the Plotter.

Keep the API for OptsBase handy, and maybe a copy of the source open in your editor, as a handy reference for all the plotting options you can set.

Instance Variable opts A dict of options.
Method set Before this subplot is drawn, do a set_name=value command to the axes. You can call this method as many times as you like with a different attribute name and value.
Method prevOpts Lets you use my previous local options (or the current ones, if there are no previous ones) inside a context call.
Method add_annotation Adds the text supplied after index k at an annotation of the plotted vector.
Method add_axvline Adds a vertical dashed line at the data point with integer index k. You can use negative indices, e.g., -1 for the last data point.
Method add_color Appends the supplied line style character to the list of colors being used.
Method add_legend Adds the supplied format-substituted text to the list of legend entries.
Method add_line Appends the supplied line style string(s) to my list of line styles being used.
Method add_lines Alias for add_line.
Method add_marker Appends the supplied marker style character to the list of markers being used.
Method add_plotKeyword Add a keyword to the underlying Matplotlib plotting call.
Method add_textBox Adds a text box to the specified location of the subplot.
Method clear_annotations Clears the list of annotations.
Method clear_legend Clears the list of legend entries.
Method clear_plotKeywords Clears all keywords for this subplot.
Method clear_textBoxes Clears the dict of text boxes.
Method plot Specifies a non-logarithmic regular plot, unless called with the name of a different plot type.
Method plot_bar Specifies a bar plot, unless called with False.
Method plot_error Specifies an error bar plot, unless called with False.
Method plot_loglog Makes both axes logarithmic, unless called with False.
Method plot_semilogx Makes x-axis logarithmic, unless called with False.
Method plot_semilogy Makes y-axis logarithmic, unless called with False.
Method plot_stem Specifies a stem plot, unless called with False.
Method plot_step Specifies a step plot, unless called with False.
Method set_axisExact Forces the limits of the named axis ("x" or "y") to exactly the data range, unless called with False.
Method set_colors Sets the list of colors. Call with no args to clear the list and revert to default color scheme.
Method set_firstVectorTop Has the first dependent vector (the second argument to the Plotter object call) determine the top (maximum) of the displayed plot boundary.
Method set_fontsize Sets the fontsize of the specified artist name.
Method set_legend Sets the list of legend entries.
Method set_tickSpacing Sets the major tick spacing for axisName ("x" or "y"), and minor tick spacing as well.
Method set_title Sets a title for all subplots (if called out of context) or for just the present subplot (if called in context).
Method set_xlabel Sets the x-axis label.
Method set_ylabel Sets the y-axis label.
Method set_zeroBottom Sets the bottom (minimum) of the Y-axis range to zero, unless called with False.
Method set_zeroLine Draws a horizontal line at the specified y value (default is y=0) if the Y-axis range includes that value.
Method use_bump Bumps up the common y-axis upper limit to 120% of what Matplotlib decides. Call with False to disable the bump.
Method use_grid Adds a grid, unless called with False.
Method use_legend Has an automatic legend entry added for each plot line, unless called with False.
Method use_labels Has annotation labels point to each plot line instead of a legend, with text taken from the legend list. (Works best in interactive apps.)
Method use_minorTicks Enables minor ticks for axisName ("x" or "y", omit for both). Call with False after the axisName to disable.
Method use_timex Uses intelligent time scaling for the x-axis, unless called with False.
Method hide_axis Hide the x-axis and y-axis (for images).
opts =
A dict of options.
def set(self, name, value):

Before this subplot is drawn, do a set_name=value command to the axes. You can call this method as many times as you like with a different attribute name and value.

Use this method in place of calling the Plotter instance with keywords. Now, such keywords are sent directly to the underlying Matplotlib plotting call.

@contextmanager
def prevOpts(self):

Lets you use my previous local options (or the current ones, if there are no previous ones) inside a context call.

def add_annotation(self, k, proto, *args, **kw):

Adds the text supplied after index k at an annotation of the plotted vector.

If there is more than one vector being plotted within the same subplot, you can have the annotation refer to a vector other than the first one by setting the keyword kVector to its non-zero index.

The annotation points to the point at index k of the plotted vector, unless k is a float. In that case, it points to the point where the vector is closest to that float value.

You may include a text prototype with format-substitution args following it, or just supply the final text string with no further arguments. If you supply just an integer or float value with no further arguments, it will be formatted reasonably.

You can set the annotation to the first y-axis value that crosses a float value of k by setting y True.

Note: Your code needs to make sure that you are really passing an integer value of k if that's what you intend. If it's a float, the annotation will go where you don't expect it to.

See Alsoclear_annotations.
def add_axvline(self, k):

Adds a vertical dashed line at the data point with integer index k. You can use negative indices, e.g., -1 for the last data point.

To place the dashed line at (or at least near) an x value, use a float for k.

def add_color(self, x=None):

Appends the supplied line style character to the list of colors being used.

The first and possibly only color in the list applies to the first vector plotted within a given subplot. If there are additional vectors being plotted within a given subplot (three or more arguments supplied when calling the Plotter object, more than the number of colors that have been added to the list, then the colors rotate back to the first one in the list.

If you never call this and don't set your own list with a call to set_colors, a default color list is used.

If no color code or None is supplied, reverts to the default color scheme.

def add_legend(self, proto, *args):

Adds the supplied format-substituted text to the list of legend entries.

You may include a text prototype with format-substitution args, or just supply the final text string with no further arguments.

See Alsoclear_legend, set_legend.
def add_line(self, *args, **kw):

Appends the supplied line style string(s) to my list of line styles being used.

The first and possibly only line style in the list applies to the first vector plotted within a given subplot. If there is an additional vector being plotted within a given subplot (three or more arguments supplied when calling the Plotter object, and more than one line style has been added to the list, then the second line style in the list is used for that second vector plot line. Otherwise, the first (only) line style in the list is used for the second plot line as well.

If no line style character or None is supplied, clears the list of line styles.

ParameterswidthA width for the line(s). If you want separate line widths for different lines, call this repeatedly with each seperate line style and width. (You can make the width a second argument of a 2-arg call, after a single line style string.)
def add_lines(self, *args, **kw):

Alias for add_line.

def add_marker(self, x, size=None):

Appends the supplied marker style character to the list of markers being used.

The first and possibly only marker in the list applies to the first vector plotted within a given subplot. If there is an additional vector being plotted within a given subplot (three or more arguments supplied when calling the Plotter object, and more than one marker has been added to the list, then the second marker in the list is used for that second vector plot line. Otherwise, the first (only) marker in the list is used for the second plot line as well.

You can specify a size for the marker as well.

def add_plotKeyword(self, name, value):

Add a keyword to the underlying Matplotlib plotting call.

See Alsoclear_plotKeywords.
def add_textBox(self, location, proto, *args):

Adds a text box to the specified location of the subplot.

Here are the locations (you can use the integer instead of the abbreviation if you want), along with their text alignments:

  1. "NE": right, top.
  2. "E": right, middle.
  3. "SE": right, bottom.
  4. "S": middle, bottom.
  5. "SW": left, bottom.
  6. "W": left, middle.
  7. "NW": left, top.
  8. "N": middle, top.
  9. "M": middle of plot.

If there's already a text box at the specified location, a line will be added to it.

You may include a text prototype with format-substitution args, or just supply the final text string with no further arguments.

See Alsoclear_textBoxes.
def clear_annotations(self):

Clears the list of annotations.

def clear_legend(self):

Clears the list of legend entries.

def clear_plotKeywords(self):

Clears all keywords for this subplot.

def clear_textBoxes(self):

Clears the dict of text boxes.

def plot(self, call='plot'):

Specifies a non-logarithmic regular plot, unless called with the name of a different plot type.

def plot_bar(self, yes=True):

Specifies a bar plot, unless called with False.

def plot_error(self, yes=True):

Specifies an error bar plot, unless called with False.

def plot_loglog(self, yes=True):

Makes both axes logarithmic, unless called with False.

def plot_semilogx(self, yes=True):

Makes x-axis logarithmic, unless called with False.

def plot_semilogy(self, yes=True):

Makes y-axis logarithmic, unless called with False.

def plot_stem(self, yes=True):

Specifies a stem plot, unless called with False.

def plot_step(self, yes=True):

Specifies a step plot, unless called with False.

def set_axisExact(self, axisName, yes=True):

Forces the limits of the named axis ("x" or "y") to exactly the data range, unless called with False.

def set_colors(self, *args):

Sets the list of colors. Call with no args to clear the list and revert to default color scheme.

Supply a list of color codes, either as a single argument or with one entry per argument.

def set_firstVectorTop(self):

Has the first dependent vector (the second argument to the Plotter object call) determine the top (maximum) of the displayed plot boundary.

def set_fontsize(self, name, fontsize):

Sets the fontsize of the specified artist name.

Recognized names are 'title', 'xlabel', 'ylabel', 'legend', 'annotations', and 'textbox'.

def set_legend(self, *args, **kw):

Sets the list of legend entries.

Supply a list of legend entries, either as a single argument or with one entry per argument. You can set the fontsize keyword to the desired fontsize of the legend; the default is 'small'.

See Alsoadd_legend, clear_legend.
def set_tickSpacing(self, axisName, major, minor=None):

Sets the major tick spacing for axisName ("x" or "y"), and minor tick spacing as well.

For each setting, an int will set a maximum number of tick intervals, and a float will set a spacing between intervals.

You can set minor True to have minor ticks set automatically, or False to have them turned off. (Major ticks are set automatically by default, and cannot be turned off.)

def set_title(self, proto, *args):

Sets a title for all subplots (if called out of context) or for just the present subplot (if called in context).

You may include a text prototype with format-substitution args, or just supply the final text string with no further arguments.

def set_xlabel(self, x):

Sets the x-axis label.

Ignored if time-x mode has been activated with a call to set_timex. If called out of context, on the Plotter instance, this x-label is used for all subplots and only appears in the last (bottom) subplot of each column of subplots.

def set_ylabel(self, x):

Sets the y-axis label.

def set_zeroBottom(self, yes=True):

Sets the bottom (minimum) of the Y-axis range to zero, unless called with False.

This is useful for plotting values that are never negative and where zero is a meaningful absolute minimum.

def set_zeroLine(self, y=0, color='black', linestyle='--', linewidth=1):

Draws a horizontal line at the specified y value (default is y=0) if the Y-axis range includes that value.

If y is None or False, clears any previously set line.

ParameterscolorSet the line color (default: black).
linestyleSet the line type (default: '--').
linewidthSet the line width (default: 1).
def use_bump(self, yes=True):

Bumps up the common y-axis upper limit to 120% of what Matplotlib decides. Call with False to disable the bump.

def use_grid(self, *args):

Adds a grid, unless called with False.

The behavior this method is a little different than it used to be. You can still enable a default grid by calling it with no arguments, or turn off the grid entirely by supplying False as that sole argument. But now specifying a custom grid has become a lot more powerful.

To turn gridlines on for just one axis's major tics, supply that axis name as an argument followed by 'major'. (Not case-sensitive.) For example, use_grid('x', 'major') enables only vertical grid lines at major tics of the 'x' axis.

To turn gridlines on for both major and minor ticks, use 'both', like this: use_grid('both'). Or, for major and minor ticks on just the 'y' axis, for example, use_grid('y', 'both'). You can also use the term 'minor' to have grid lines just at minor ticks, though it's not evident why you would want that as opposed to 'both'.

To have different grid lines for different axes, supply each axis name followed by its tick specifier. For example, to have horizontal grid lines at both major and minor ticks of the 'y' axis but vertical lines just at major tick locations on the 'x' axis, do this::

   use_grid('x', 'both', 'y', 'major')
def use_legend(self, yes=True):

Has an automatic legend entry added for each plot line, unless called with False.

def use_labels(self, yes=True):

Has annotation labels point to each plot line instead of a legend, with text taken from the legend list. (Works best in interactive apps.)

Call with False to revert to default legend-box behavior.

def use_minorTicks(self, axisName=None, yes=True):

Enables minor ticks for axisName ("x" or "y", omit for both). Call with False after the axisName to disable.

To enable with a specific tick spacing, supply a float instead of just True. Or, for a specific number of ticks, supply that as an int.

Note that, due to a Matplotlib limitation, you can't enable minor ticks for just one axis, although you can independently set the tick spacings.

def use_timex(self, yes=True):

Uses intelligent time scaling for the x-axis, unless called with False.

If your x-axis is for time with units in seconds, you can call this to have the X values rescaled to the most sensible units, e.g., nanoseconds for values < 1E-6. Any xlabel option is disregarded in such case because the x label is set automatically.

def hide_axis(self, yes=True):

Hide the x-axis and y-axis (for images).

Call with False to revert to default show-axis behavior.

API Documentation for yampex, generated by pydoctor at 2022-11-21 15:03:54.