I provide a Matplotlib Figure with one or more time-vector and XY subplots of Numpy vectors.

Construct an instance of me with the total number of subplots (to be intelligently apportioned into one or more rows and columns) or, with two constructor arguments, the number of columns followed by the number of rows.

With the filePath keyword, you can specify the file path of a PNG file for me to create or overwrite with each call to show.

You can set the width and height of the Figure with constructor keywords, and (read-only) access them via my properties of the same names. Or set my figSize attribute (in a subclass or with that constructor keyword) to a 2-sequence with figure width and height. The default width and height is just shy of the entire monitor size.

The dimensions are in inches, converted to pixels at 100 DPI, unless they are both integers and either of them exceeds 75 (which would equate to a huge 7,500 pixels). In that case, they are considered to specify the pixel dimensions directly.

Use the "Agg" backend by supplying the constructor keyword useAgg. This works better for plotting to an image file, and is selected automatically if you supply a filePath to the constructor. Be aware that, once selected, that backend will be used for all instances of me. If you're using the "Agg" backend, you should specify it the first time an instance is constructed.

Setting the verbose keyword True puts out a bit of info about annotator positioning. Not for regular use.

Any other keywords you supply to the constructor are supplied to the underlying Matplotlib plotting call for all subplots.

Keep the API for OptsBase handy, and maybe a copy of the source, to see all the plotting options you can set.

Instance Variable dims A dict (actually, a subclass of Dims) of sub-dicts of the dimensions of various text objects, keyed first by subplot index then the object name.
Instance Variable Nsp The number of subplots defined thus far defined with calls to my instance.
Class Method setupClass Called by each instance of me during instantiation. Sets a class-wide Matplotlib pyplot import the first time it's called.
Class Method showAll Calls show for the figures generated by all instances of me.
Method __init__ Constructor possibilities (not including keywords, except Nc):
Static Method parseArgs Parse the supplied args and kw for a constructor call.
Method reset Clears everything out to start fresh.
Method __del__ Safely ensures that I am removed from the class-wide ph instance of PlotterHolder.
Method width Figure width (inches).
Method height Figure height (inches).
Method __getattr__ You can access plotting methods and a given subplot's plotting options as attributes.
Method __enter__ Upon an outer context entry, sets up the first subplot with cleared axes, preserves a copy of my global options, and returns a reference to myself as a subplotting tool.
Method __exit__ Upon completion of context, turns minor ticks and grid on if enabled for this subplot's axis, restores global (all subplots) options.
Method start An alternative to the context-manager way of using me. Just call this method and a reference to myself as a subplotting tool will be returned.
Method done Call this after a call to start when done plotting. This is the alternative to the context-manager way of using me.
Method subplots_adjust Adjusts spacings.
Method updateAnnotations Updates the positions of all annotations in an already-drawn plot.
Method show Call this to show the figure with suplots after the last call to my instance.
Method clear Clears my figure with all annotators and artist dimensions. Removes my ID from the class-wide PlotterHolder.
Method xBounds See Subplotter.xBounds.
Method yBounds See Subplotter.yBounds.
Method fontsize Undocumented
Method doKeywords Applies line style/marker/color settings as keywords for this vector, except for options already set with keywords.
Method doSettings Does set_XXX calls on the Axes object for the subplot at index k.
Method __call__ In the next (perhaps first) subplot, or one whose index is specified with keyword k, plots the second supplied vector (and any further ones) versus the first.
Method _maybePixels Considers the supplied figSize to be in pixels if both its elements are integers and at least one of them exceeds 75. In that case, scales it down by DPI.
Method _doPlots This gets called by __call__ at the beginning of each call to my subplot-context instance, and by __exit__ when subplot context ends, to do all the plotting for the previous subplot.

Inherited from OptsBase:

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).
dims =
A dict (actually, a subclass of Dims) of sub-dicts of the dimensions of various text objects, keyed first by subplot index then the object name.
Nsp =
The number of subplots defined thus far defined with calls to my instance.
@classmethod
def setupClass(cls, useAgg=False):

Called by each instance of me during instantiation. Sets a class-wide Matplotlib pyplot import the first time it's called.

If any instance of me is using the Agg renderer, all instances will.

@classmethod
def showAll(cls):

Calls show for the figures generated by all instances of me.

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

Constructor possibilities (not including keywords, except Nc):

Plotter(Nc, Nr): Specify Nc columns and Nr rows.

Plotter(N): Specify up to N subplots in optimal arrangement of columns and rows.

Plotter(N, Nc=x): Specify up to N columns subplots with x columns.

Plotter(Nc, Nr, V): Specify Nc columns and Nr rows, with container object V.

Plotter(Nc, Nr, V): Specify up to N subplots in optimal arrangement of columns and rows, with container object V.

Plotter(N, V, Nc=x): Specify up to N columns subplots with x columns, with container object V.

ParametersfilePathSpecify the path of a PNG file to be created instead of a plot window being opened. (Implies useAgg.)
useAggSet True to use the "Agg" backend, which works better for creating image files. If you're going to specify it for multiple plot images, do so the first time an instance of me is constructed.
figSizeSet to a 2-sequence with figure width and height if not using the default, which is just shy of your entire monitor size. Dimensions are in inches, converted to pixels at 100 DPI, unless both are integers and either exceeds 75. Then they are considered to specify the pixel dimensions directly.
widthSpecify the figure width part of figSize.
heightSpecify the figure height part of figSize.
h2A single index, or a sequence or set containing one or more indices, of any rows (starting with 0 for the top row) that have twice the normal height. If an invalid index is included, an exception will be raised.
w2A single index, or a sequence or set containing one or more indices, of any columns (starting with 0 for the left column) that have twice the normal width. If an invalid index is included, an exception will be raised.
@staticmethod
def parseArgs(*args, **kw):

Parse the supplied args and kw for a constructor call.

Returns a 5-tuple with a revised args list and kw dict, the number of subplots, the number of columns, and the number of rows.

def reset(self):

Clears everything out to start fresh.

def __del__(self):

Safely ensures that I am removed from the class-wide ph instance of PlotterHolder.

def _maybePixels(self, figSize):

Considers the supplied figSize to be in pixels if both its elements are integers and at least one of them exceeds 75. In that case, scales it down by DPI.

Returns the figSize in inches.

@property
def width(self):

Figure width (inches).

@property
def height(self):

Figure height (inches).

def __getattr__(self, name):

You can access plotting methods and a given subplot's plotting options as attributes.

If you request a plotting method, you'll get an instance of me with my _plotter method set to name first.

def __enter__(self):

Upon an outer context entry, sets up the first subplot with cleared axes, preserves a copy of my global options, and returns a reference to myself as a subplotting tool.

def __exit__(self, *args):

Upon completion of context, turns minor ticks and grid on if enabled for this subplot's axis, restores global (all subplots) options.

If the Agg rendererer is not being used (for generating PNG files), also sets a hook to adjust the subplot spacings and annotation positions upon window resizing.

The args are just placeholders for the three args that contextmanager supplies at the end of context: exc_type, exc_val, exc_tb. (None are useful here.)

See Also_doPlots.
def start(self):

An alternative to the context-manager way of using me. Just call this method and a reference to myself as a subplotting tool will be returned.

Call done when finished, which is the same thing as exiting my subplotting context.

def done(self):

Call this after a call to start when done plotting. This is the alternative to the context-manager way of using me.

Note: If you don't call this to close out a plotting session with the alternative method, the last subplot will not get drawn!

See Alsostart, which gets called to start the alternative-method plotting session.
def subplots_adjust(self, *args):

Adjusts spacings.

def updateAnnotations(self, annotator=None):

Updates the positions of all annotations in an already-drawn plot.

When PlotHelper calls this, it will supply the annotator for its subplot.

def _doPlots(self):

This gets called by __call__ at the beginning of each call to my subplot-context instance, and by __exit__ when subplot context ends, to do all the plotting for the previous subplot.

Adds minor ticks and a grid, depending on the subplot-specific options. Then calls Opts.newLocal on my opts to create a new set of local options.

def show(self, windowTitle=None, fh=None, filePath=None, noShow=False):

Call this to show the figure with suplots after the last call to my instance.

If I have a non-None fc attribute (which must reference an instance of Qt's FigureCanvas, then the FigureCanvas is drawn instead of PyPlot doing a window show.

You can supply an open file-like object for PNG data to be written to (instead of a Matplotlib Figure being displayed) with the fh keyword. (It's up to you to close the file object.)

Or, with the filePath keyword, you can specify the file path of a PNG file for me to create or overwrite. (That overrides any filePath you set in the constructor.)

def clear(self):

Clears my figure with all annotators and artist dimensions. Removes my ID from the class-wide PlotterHolder.

def xBounds(self, *args, **kw):
def yBounds(self, *args, **kw):
def fontsize(self, name, default=None):
Undocumented
def doKeywords(self, kVector, kw):

Applies line style/marker/color settings as keywords for this vector, except for options already set with keywords.

Then applies plot keywords set via the set_plotKeyword call and then, with higher priority, those set via the constructor, if they don't conflict with explicitly set keywords to this call which takes highest priority.

Returns the new kw dict.

def doSettings(self, k):

Does set_XXX calls on the Axes object for the subplot at index k.

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

In the next (perhaps first) subplot, or one whose index is specified with keyword k, plots the second supplied vector (and any further ones) versus the first.

If you supply a container object that houses vectors and provides access to them as items as the first argument, you can supply vector names instead of the vectors themselves. The container object must evaluate b in a as True if it contains a vector with b, and must return the vector with a[b].

Many options can be set via the methods in OptsBase, including a title, a list of plot markers and linestyles, and a list of legend entries for the plots with those keywords.

Set useLabels to True to have annotation labels pointing to each plot line instead of a legend, with text taken from the legend list.

You can override my default plotter by specifying the name of another one with the plotter keyword, e.g., plotter="step". But the usual way to do that is to call the corresponding method of my instance, e.g., sp.step(X, Y).

Any other keywords you supply to this call are supplied to the underlying Matplotlib plotting call. (NOTE: This is a change from previous versions of Yampex where keywords to this method were used to set_X the axes, e.g., ylabel="foo" results in a set_ylabel("foo") command to the axes object, for this subplot only. Use the new OptsBase.set command instead.)

Returns a SpecialAx wrapper object for the Axes object created for the plot.

If you want to do everything with the next subplot on your own, bit by bit, and only want a reference to its Axes object (still with special treatment via SpecialAx) just call this with no args.

For low-level Matplotlib operations, you can access the underlying Axes object via the returned SpecialAx object's ax attribute. But none of its special features will apply to what you do that way.

ParameterskSet this to the integer index of the subplot you want the supplied vectors plotted in if not in sequence.
See Also_doPlots.
API Documentation for yampex, generated by pydoctor at 2022-11-21 15:03:54.