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
You can set the width and height of the Figure in inches (calculated with 100 DPI) 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 in inches. The default width and height is just shy of the entire monitor size.
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.
|Instance Variable||dims||A dict of sub-dicts of the dimensions of various text objects, keyed first by subplot index then the object name.|
|Class Method||setup||Called by each instance of me during instantiation. Sets a class-wide Matplotlib pyplot import the first time it's called.|
|Method||__del__||Safely ensures that I am removed from the class-wide ph instance
|Method||width||Figure width (inches).|
|Method||height||Figure height (inches).|
|Method||__nonzero__||I evaluate as
|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, and restores global (all subplots) options.|
|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
|Method||doKeywords||Applies line style/marker/color settings as keywords for this vector, except for options already set with keywords.|
|Method||__call__||In the next (perhaps first) subplot, plots the second supplied vector (and any further ones) versus the first.|
|Method||_doPlots||This gets called by
Inherited from OptsBase:
|Method||set||Before this subplot is drawn, do a
|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.|
|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_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 quadrant 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
|Method||plot_error||Specifies an error bar plot, unless called with
|Method||plot_loglog||Makes both axes logarithmic, unless called with
|Method||plot_semilogx||Makes x-axis logarithmic, unless called with
|Method||plot_semilogy||Makes y-axis logarithmic, unless called with
|Method||plot_stem||Specifies a stem plot, unless called with
|Method||plot_step||Specifies a step plot, unless called with
|Method||set_axisExact||Forces the limits of the named axis ("x" or "y") to
exactly the data range, unless called with
|Method||set_axvline||Adds a vertical dashed line at the data point with integer index k.|
|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
|Method||set_fontsize||Sets the fontsize of the specified artist name.|
|Method||set_grid||Adds a grid, unless called with
|Method||set_legend||Sets the list of legend entries.|
|Method||set_minorTicks||Enables minor ticks for axisName ("x" or "y").|
|Method||set_tickSpacing||Sets the major tick spacing for axisName ("x" or "y"), and minor tick spacing as well.|
|Method||set_timex||Uses intelligent time scaling for the x-axis, unless called with
|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_useLabels||Has annotation labels point to each plot line instead of a legend, with text taken from the legend list.|
|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
|Method||set_zeroLine||Adds 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
|Method||use_grid||Adds a grid, unless called with
|Method||use_legend||Has an automatic legend entry added for each plot line, unless called
|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_timex||Uses intelligent time scaling for the x-axis, unless called with
def setup(cls, useAgg=False):
Called by each instance of me during instantiation. Sets a class-wide Matplotlib pyplot import the first time it's called.
the figures generated by all instances of me.
Safely ensures that I am removed from the class-wide ph instance
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.
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.
Upon completion of context, turns minor ticks and grid on if enabled for this subplot's axis, and restores global (all subplots) options.
Adds minor ticks and a grid, depending on the subplot-specific options.
my opts to create a new set of local options.
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.)
Clears my figure with all annotators and artist dimensions. Removes my
ID from the class-wide
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.
In the next (perhaps first) subplot, 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
True if it contains a vector with b, and
must return the vector with
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
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.,
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.,
results in a
set_ylabel("foo") command to the
axes object, for this subplot only. Use the new
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
ax attribute. But none of its special features will apply to what
you do that way.