cape.tnakit.plot_mpl: Matplotlib/Pyplot Interfaces

This module contains handles to various matplotlib plotting methods. In particular, it centralizes some of the multiple-line instructions that are used in multiple places. An example is placing labels on one or more corners of the axis window.

It also includes syntax to import modules without raising ImportError.

class cape.tnakit.plot_mpl.MPLHandle(**kw)

Container for handles from matplotlib.pyplot

Versions:
  • 2019-12-20 @ddalle: First version

add(h1)

Combine two plot handle objects

Attributes of h1 will override those of h except where the attribute is a list. For example, h1.lines will be added to h.lines to get handles to lines from both instances.

Call:
>>> h.add(h1)
Inputs:
h: MPLHandle

Parent handle

h1: MPLHandle

Second handle for collecting all objects

Versions:
  • 2019-12-26 @ddalle: First version

close()

Close the open figure, if any

Call:
>>> h.close()
Inputs:
h: MPLHandle

Matplotlib object handle

Versions:
  • 2022-05-17 @ddalle: Version 1.0

save(attr, v)

Save one plot object without erasing others

This method provides a simple method to save multiple instances of a certain kind of plot object without having to perform checks manually. For example if h.lines already contains several lines, and L contains several new ones, then h.save("lines", L) will effectively run h.lines += L.

Conversions from single object to list are handled automatically, and items are only added to the list if not already present. Thus running save() several times in a row with the same arguments will not create the illusion of many objects for a given attribute.

Call:
>>> h.save(attr, v)
Inputs:
h: MPLHandle

Matplotlib object handle

attr: str

Name of attribute to save

v: any

Value to save/add for that attribute

Versions:
  • 2020-01-25 @ddalle: First version

class cape.tnakit.plot_mpl.MPLOpts(_optsdict=None, _warnmode=1, **kw)

Options class for all plot methods in plot_mpl module

Call:
>>> opts = MPLOpts(**kw)
Inputs:
kw: dict

Keyword options to be filtered and mapped

Outputs:
opts: plot_mpl.MPLOpts

Options from kwargs with defaults applied

Versions:
  • 2020-01-23 @ddalle: Version 2.0 based on KwargHandler

axadjust_col_options()

Process options for axes margin adjustment

Call:
>>> kw = opts.axadjust_col_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
MarginBottom: {None} | float

Figure fraction from bottom edge to bottom label

MarginLeft: {None} | float

Figure fraction from left edge to left-most label

MarginRight: {None} | float

Figure fraction from right edge to right-most label

MarginTop: {None} | float

Figure fraction from top edge to top-most label

MarginVSpace, vspace: {None} | float

Figure fraction for vertical space between axes

AdjustBottom: {None} | float

Figure-scale coordinates of bottom of axes

AdjustLeft: {None} | float

Figure-scale coordinates of left side of axes

AdjustRight: {None} | float

Figure-scale coordinates of right side of axes

AdjustTop: {None} | float

Figure-scale coordinates of top of axes

SubplotList: {None} | list[int]

List of subplots to put in row/column

SubplotRubber: {None} | int

Index of subplot to expand

Outputs:
kw: dict

Dictionary of options to axes_adjust_col()

Versions:
  • 2020-01-10 @ddalle: First version

  • 2020-01-18 @ddalle: Using KwargHandler

axadjust_options()

Process options for axes margin adjustment

Call:
>>> kw = opts.axadjust_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
MarginBottom: {None} | float

Figure fraction from bottom edge to bottom label

MarginLeft: {None} | float

Figure fraction from left edge to left-most label

MarginRight: {None} | float

Figure fraction from right edge to right-most label

MarginTop: {None} | float

Figure fraction from top edge to top-most label

AdjustBottom: {None} | float

Figure-scale coordinates of bottom of axes

AdjustLeft: {None} | float

Figure-scale coordinates of left side of axes

AdjustRight: {None} | float

Figure-scale coordinates of right side of axes

AdjustTop: {None} | float

Figure-scale coordinates of top of axes

KeepAspect: {None} | True | False

Keep aspect ratio; default is True unless``ax.get_aspect()`` is "auto"

Subplot, subplot: {None} | Axes | int

Subplot index (1-based)

SubplotCols: {None} | int > 0

Expected number of subplot columns

SubplotRows: {None} | int > 0

Expected number of subplot rows

Outputs:

“CoverageCDF”: CoverageOptions.Coverage, * 2020-01-08 @ddalle: First version * 2020-01-18 @ddalle: Using KwargHandler

axadjust_row_options()

Process options for axes margin adjustment

Call:
>>> kw = opts.axadjust_row_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
MarginBottom: {None} | float

Figure fraction from bottom edge to bottom label

MarginLeft: {None} | float

Figure fraction from left edge to left-most label

MarginRight: {None} | float

Figure fraction from right edge to right-most label

MarginTop: {None} | float

Figure fraction from top edge to top-most label

MarginHSpace, hspace: {None} | float

Figure fraction for horizontal space between axes

AdjustBottom: {None} | float

Figure-scale coordinates of bottom of axes

AdjustLeft: {None} | float

Figure-scale coordinates of left side of axes

AdjustRight: {None} | float

Figure-scale coordinates of right side of axes

AdjustTop: {None} | float

Figure-scale coordinates of top of axes

SubplotList: {None} | list[int]

List of subplots to put in row/column

SubplotRubber: {None} | int

Index of subplot to expand

Outputs:
kw: dict

Dictionary of options to axes_adjust_row()

Versions:
  • 2020-01-10 @ddalle: First version

  • 2020-01-18 @ddalle: Using KwargHandler

axes_options()

Process options for axes handle

Call:
>>> kw = opts.axes_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
ax, Axes: {None} | matplotlib.axes._subplots.Axes

Handle to existing axes

AxesOptions: {None} | dict

Options to AxesSubplot

Outputs:
kw: dict

Dictionary of options to plt.axes()

Versions:
  • 2019-03-07 @ddalle: First version

  • 2019-12-20 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

axformat_options()

Process options for axes format

Call:
>>> kw = opts.axformat_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
Density, density: {True} | False

Option to scale histogram plots

Index, i: {0} | int >=0

Index to select specific option from lists

Pad: {None} | float

Padding to add to both axes, ax.set_xlim and ax.set_ylim

Rotate, rotate: {True} | False

Option to flip x and y axes

XLabel, xlabel: {None} | str

Label to put on x axis

XLim, xlim: {None} | (float, float)

Limits for min and max value of x-axis

XLimMax: {None} | float

Min value for x-axis in plot

XLimMin: {None} | float

Max value for x-axis in plot

XPad: {Pad} | float

Extra padding to add to x axis limits

YLabel, ylabel: {None} | str

Label to put on y axis

YLim, ylim: {None} | (float, float)

Limits for min and max value of y-axis

YLimMax: {None} | float

Min value for y-axis in plot

YLimMin: {None} | float

Max value for y-axis in plot

YPad: {Pad} | float

Extra padding to add to y axis limits

Outputs:
kw: dict

Dictionary of options to axes_format()

Versions:
  • 2019-03-07 @jmeeroff: First version

  • 2020-01-18 @ddalle: Using KwargHandler

contour_options()

Process options for contour plots

Call:
>>> kw = opts.contour_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
Index, i: {0} | int >=0

Index to select specific option from lists

Rotate, rotate: {True} | False

Option to flip x and y axes

ContourType: {tricontourf} | tricontour | tripcolor

Contour type specifier

ContourLevels: {None} | int | np.ndarray

Number or list of levels for contour plots

ContourOptions: {None} | dict

Options to plt.tricontour() and variants

MarkPoints: {True} | False

Put a marker at contributing data points

MarkerColor: {None} | str | tuple

Color for markers in MarkerOptions

MarkerOptions: {None} | dict

Options for markers on non-plot() functions

MarkerSize: {None} | int | float

markersize passed to MarkerOptions

Label, label, lbl: {None} | str

Label passed to plt.legend()

ContourColorMap: {None} | str

Color map for contour plots

Outputs:
kw: dict

Dictionary of options to contour()

Versions:
  • 2020-03-26 @jmeeroff: First version

coverage_options()

Process options for coverage intervals

Call:
>>> kw = opts.coverage_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options for coverage intervals

Versions:
  • 2019-03-05 @ddalle: First version

  • 2019-12-21 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

delta_options()

Process options for delta plots

Call:
>>> kw = opts.delta_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options for mpl._plot

Versions:
  • 2019-03-05 @ddalle: First version

  • 2019-12-21 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

deltalabel_options()

Process options for delta labels

Call:
>>> kw = opts.deltalabel_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options for mpl.axlabel

Versions:
  • 2019-03-05 @ddalle: First version

  • 2019-12-21 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

error_options()

Process options for error plots

Call:
>>> kw = opts.error_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
Index, i: {0} | int >=0

Index to select specific option from lists

Rotate, rotate: {True} | False

Option to flip x and y axes

ErrorOptions: {None} | dict

Options for error plots

ErrorPlotType: "FillBetween" | {"ErrorBar"}

Plot type for “error” plots

ErrorBarOptions, ErrorBarOpts: {None} | dict

Options for errorbar() plots

ErrorBarMarker: {None} | str

Marker for errorbar() plots

FillBetweenOptions, FillBetweenOpts: {None} | dict

Options for fill_between() plots

PlotOptions, PlotOpts: {None} | dict

Options to plt.plot() for primary curve

Outputs:
kw: dict

Dictionary of options to error()

Versions:
  • 2019-03-04 @ddalle: First version

  • 2019-12-23 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

errorbar_options()

Process options for errorbar() calls

Call:
>>> kw = opts.errorbar_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
ErrorBarOptions, ErrorBarOpts: {None} | dict

Options for errorbar() plots

Index, i: {0} | int >=0

Index to select specific option from lists

Rotate, rotate: {True} | False

Option to flip x and y axes

ErrorBarMarker: {None} | str

Marker for errorbar() plots

PlotOptions, PlotOpts: {None} | dict

Options to plt.plot() for primary curve

Outputs:
kw: dict

Dictionary of options to errorbar()

Versions:
  • 2019-03-05 @ddalle: First version

  • 2019-12-21 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

figure_options()

Process options specific to Matplotlib figure

Call:
>>> kw = figure_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
fig, Figure: {None} | matplotlib.figure.Figure

Handle to existing figure

FigOptions: {None} | dict

Options to matplotlib.figure.Figure

FigNumber, nfig, numfig: {None} | int > 0

Figure number

FigWidth, wfig: {None} | float > 0.0

Figure width [inches]

FigHeight, hfig: {None} | float > 0.0

Figure height [inches]

FigDPI: {None} | int > 0 | float > 0.0

Figure resolution in dots per inch

Outputs:
kw: dict

Dictionary of options to plt.figure()

Versions:
  • 2019-03-06 @ddalle: First version

  • 2019-12-20 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

fillbetween_options()

Process options for fill_between() calls

Call:
>>> kw = opts.fillbetween_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
FillBetweenOptions, FillBetweenOpts: {None} | dict

Options for fill_between() plots

Index, i: {0} | int >=0

Index to select specific option from lists

Rotate, rotate: {True} | False

Option to flip x and y axes

PlotOptions, PlotOpts: {None} | dict

Options to plt.plot() for primary curve

Outputs:
kw: dict

Dictionary of options to fill_between()

Versions:
  • 2019-03-05 @ddalle: First version

  • 2019-12-21 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

font_options()

Process global font options

Call:
>>> kw = opts.font_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of font property options

Versions:
  • 2019-03-07 @ddalle: First version

  • 2019-12-19 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

gauss_options()

Process options to gaussian plot curve

Call:
>>> kw = opts.gauss_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
NGauss, ngauss: {151} | int

Number of points to sample Gaussian plot

HistGaussianOptions: {None} | dict

Plot options for gaussian plot on histogram

Index, i: {0} | int >=0

Index to select specific option from lists

Rotate, rotate: {True} | False

Option to flip x and y axes

PlotOptions, PlotOpts: {None} | dict

Options to plt.plot() for primary curve

Outputs:
kw: dict

Dictionary of options to plot()

Versions:
  • 2019-03-07 @ddalle: First version

  • 2019-12-19 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

grid_options()

Process options to axes grid() command

Call:
>>> kw = opts.grid_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
Grid, grid: {True} | False

Option to turn on/off axes grid

GridOptions, GridOpts, MajorGridOpts, MajorGridOptions: {None} | dict

Plot options for major grid

MinorGrid: `True | {False}

Turn on/off grid at minor ticks

MinorGridOptions: {None} | dict

Plot options for minor grid

GridColor: {None} | str | tuple

Color passed to GridOptions

Outputs:
kw: dict

Dictionary of options to grid()

Versions:
  • 2019-03-07 @jmeeroff: First version

  • 2019-12-23 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

hist_options()

Process options for histogram plots

Call:
>>> kw = opts.hist_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
HistBins: {None} | int > 0

Number of histogram bins passed to HistOptions

HistColor: {None} | str | tuple

Histogram passed to HistOptions

HistOptions: {None} | dict

Plot options for histograms

Rotate, rotate: {True} | False

Option to flip x and y axes

Outputs:
kw: dict

Dictionary of options to hist()

Versions:
  • 2020-04-23 @jmeeroff: First version

histlabel_options()

Process options to gaussian plot curve

Call:
>>> kw = opts.gauss_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options to plot()

Versions:
  • 2019-03-07 @ddalle: Version 1.0

imshow_options()

Process options for image display calls

Call:
>>> kw = opts.imshow_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
ImageXMin: {0.0} | float

Coordinate for left edge of image

ImageXMax: {None} | float

Coordinate for right edge of image

ImageXCenter: {None} | float

Horizontal center coord if x edges not specified

ImageYMin: {None} | float

Coordinate for bottom edge of image

ImageYMax: {None} | float

Coordinate for top edge of image

ImageYCenter: {0.0} | float

Vertical center coord if y edges not specified

ImageExtent: {None} | tuple | list

Spec for ImageXMin, ImageXMax, ImageYMin, ImageYMax

Outputs:
kw: dict

Dictionary of options to imshow()

Versions:
  • 2020-01-09 @ddalle: First version

  • 2020-01-18 @ddalle: Using KwargHandler

interval_options()

Process options for interval() calls

Call:
>>> kw = opts.interval_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options to fill_between()

Versions:
  • 2019-03-05 @ddalle: First version

  • 2019-12-21 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

intervallabel_options()

Process options for interval label calls

Call:
>>> kw = opts.intervallabel_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options for interval labels

Versions:
  • 2019-03-05 @ddalle: First version

  • 2019-12-21 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

legend_font_options()

Process font options for legend() calls

Call:
>>> kw = opts.legend_font_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
LegendFontOptions: {None} | dict

Options to FontProperties

FontOptions: {None} | dict

Options to FontProperties

LegendFontName: {None} | str

Font name (categories like sans-serif allowed)

LegendFontSize: {None} | str | int | float

Font size (options like "small" allowed)

LegendFontStretch: {None} | str | int | float

Stretch, numeric in range 0-1000 or string such as "condensed", "extra-condensed", "semi-expanded"

LegendFontStyle: {None} | "normal" | "italic" | "oblique"

Font style/slant

LegendFontVariant: {None} | "normal" | "small-caps"

Font capitalization variant

LegendFontWeight: {None} | str | int | float

Numeric font weight 0-1000 or "normal", "bold", etc.

Outputs:
kw: dict

Dictionary of options to errorbar()

Versions:
  • 2020-01-19 @ddalle: First version

legend_options()

Process options for legend()

Call:
>>> kw = opts.legend_options(kw, kwp={})
Inputs:
kw: dict

Dictionary of options to parent function

kwp: {{}} | dict

Dictionary of options from which to inherit

Keys:
LegendOptions: {None} | dict

Options to plt.legend()

LegendAnchor: {None} | tuple(x, y)

Location passed to bbox_to_anchor

LegendFontOptions: {None} | dict

Options to FontProperties

LegendLocation: {None} | str | int

Numeric location or abbreviation

Outputs:
kw: dict

Options to legend()

Versions:
  • 2019-03-07 @ddalle: First version

  • 2019-12-23 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-98 @ddalle: Using KwargHandler

mean_options()

Process options plot mean on histogram

Call:
>>> kw = opts.mean_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options to plot()

Versions:
  • 2019-03-07 @ddalle: First version

  • 2019-12-19 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

meanlabel_options()

Process options to histogram mean labels

Call:
>>> kw = opts.meanlabe;_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options to plot()

Versions:
  • 2019-03-07 @ddalle: First version

  • 2019-12-19 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

minmax_options()

Process options for min/max plots

Call:
>>> kw = opts.minmax_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
Index, i: {0} | int >=0

Index to select specific option from lists

Rotate, rotate: {True} | False

Option to flip x and y axes

MinMaxOptions, MinMaxOpts: {None} | dict

Options for error-bar or fill-between min/max plot

MinMaxPlotType: {"FillBetween"} | "ErrorBar"

Plot type for min/max plot

ErrorBarOptions, ErrorBarOpts: {None} | dict

Options for errorbar() plots

ErrorBarMarker: {None} | str

Marker for errorbar() plots

FillBetweenOptions, FillBetweenOpts: {None} | dict

Options for fill_between() plots

PlotOptions, PlotOpts: {None} | dict

Options to plt.plot() for primary curve

Outputs:
kw: dict

Dictionary of options to minmax()

Versions:
  • 2019-03-04 @ddalle: First version

  • 2019-12-20 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

plot_options()

Process options to primary plot curve

Call:
>>> kw = opts.plot_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
Index, i: {0} | int >=0

Index to select specific option from lists

Rotate, rotate: {True} | False

Option to flip x and y axes

PlotOptions, PlotOpts: {None} | dict

Options to plt.plot() for primary curve

PlotFormat, fmt: {None} | str

Format specifier as third arg to plot()

Label, label, lbl: {None} | str

Label passed to plt.legend()

PlotColor: {None} | str | tuple

Color option to plt.plot() for primary curve

PlotLineWidth: {None} | int > 0 | float > 0.0

Line width for primary plt.plot()

PlotLineStyle: ":" | "-" | "none" | "-." | "--"

Line style for primary plt.plot()

Outputs:
kw: dict

Dictionary of options to plot()

Versions:
  • 2019-03-07 @ddalle: First version

  • 2019-12-19 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

scatter_options()

Process options for scatter() calls

Call:
>>> kw = opts.scatter_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options to scatter()

Versions:
  • 2019-03-05 @ddalle: First version

  • 2019-12-21 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

sigma_options()

Process options for sigma() calls

Call:
>>> kw = opts.sigma_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options to _plot()

Versions:
  • 2019-03-05 @ddalle: First version

  • 2019-12-21 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

sigmalabel_options()

Process options for sigma() labels

Call:
>>> kw = opts.sigma_options()
Inputs:
opts: MPLOpts

Options interface

Keys:

%(keys)s

Outputs:
kw: dict

Dictionary of options to axlabel`()

Versions:
  • 2019-03-05 @ddalle: First version

  • 2019-12-21 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

spine_options()

Process options for axes “spines”

Call:
>>> kw = opts.spine_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
Spines: {True} | False

Turn on/off all spines

SpineOptions: {None} | dict

Options for all spines

BottomSpine: {None} | True | False | "clipped"

Turn on/off bottom plot spine

BottomSpineMax: {None} | float

Maximum x coord for bottom plot spine

BottomSpineMin: {None} | float

Minimum x coord for bottom plot spine

BottomSpineOptions: {None} | dict

Additional options for bottom spine

BottomSpineTicks, BottomTicks: {None} | True | False

Turn on/off labels on bottom spine

BottomTickLabels: {None} | True | False

Turn on/off tick labels on bottom spine

LeftSpine: {None} | True | False | "clipped"

Turn on/off left plot spine

LeftSpineMax: {None} | float

Maximum y coord for left plot spine

LeftSpineMin: {None} | float

Minimum y coord for left plot spine

LeftSpineOptions: {None} | dict

Additional options for left spine

LeftSpineTicks, LeftTicks: {None} | True | False

Turn on/off labels on left spine

LeftTickLabels: {None} | True | False

Turn on/off tick labels on left spine

RightSpine: {None} | True | False | "clipped"

Turn on/off right plot spine

RightSpineMax: {None} | float

Maximum y coord for right plot spine

RightSpineMin: {None} | float

Minimum y coord for right plot spine

RightSpineOptions: {None} | dict

Additional options for right spine

RightSpineTicks, RightTicks: {None} | True | False

Turn on/off labels on right spine

RightTickLabels: {None} | True | False

Turn on/off tick labels on right spine

TopSpine: {None} | True | False | "clipped"

Turn on/off top plot spine

TopSpineMax: {None} | float

Maximum x coord for top plot spine

TopSpineMin: {None} | float

Minimum x coord for top plot spine

TopSpineOptions: {None} | dict

Additional options for top spine

TopSpineTicks, TopTicks: {None} | True | False

Turn on/off labels on top spine

TopTickLabels: {None} | True | False

Turn on/off tick labels on top spine

Outputs:
kw: dict

Dictionary of options to each of four spines

Versions:
  • 2019-03-07 @jmeeroff: First version

  • 2019-12-20 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-20 @ddalle: Using KwargHandler

uq_options()

Process options for uncertainty quantification plots

Call:
>>> kw = opts.uq_options()
Inputs:
opts: MPLOpts

Options interface

Keys:
Index, i: {0} | int >=0

Index to select specific option from lists

Rotate, rotate: {True} | False

Option to flip x and y axes

ErrorBarMarker: {None} | str

Marker for errorbar() plots

ErrorBarOptions, ErrorBarOpts: {None} | dict

Options for errorbar() plots

FillBetweenOptions, FillBetweenOpts: {None} | dict

Options for fill_between() plots

UncertaintyPlotType, UQPlotType: {"FillBetween"} | "ErrorBar"

Plot type for UQ plots

UncertaintyOptions, UQOptions, UQOpts, UncertaintyOpts: {None} | dict

Options for UQ plots

PlotOptions, PlotOpts: {None} | dict

Options to plt.plot() for primary curve

Outputs:
kw: dict

Dictionary of options to uq()

Versions:
  • 2019-03-04 @ddalle: First version

  • 2019-12-23 @ddalle: From tnakit.mpl.mplopts

  • 2020-01-17 @ddalle: Using KwargHandler

cape.tnakit.plot_mpl.axes(**kw)

Create new axes or edit one if necessary

Call:
>>> ax = axes(**kw)
Inputs:
ax, Axes: {None} | matplotlib.axes._subplots.Axes

Handle to existing axes

AxesOptions: {None} | dict

Options to AxesSubplot

Outputs:
ax: matplotlib.axes._subplots.AxesSubplot

Axes handle

Versions:
  • 2019-03-06 @ddalle: First version

  • 2020-01-24 @ddalle: Moved to plot_mpl.mpl

cape.tnakit.plot_mpl.figure(**kw)

Get or create figure handle and format it

Call:
>>> fig = figure(**kw)
Inputs:
fig, Figure: {None} | matplotlib.figure.Figure

Handle to existing figure

FigOptions: {None} | dict

Options to matplotlib.figure.Figure

FigNumber, nfig, numfig: {None} | int > 0

Figure number

FigWidth, wfig: {None} | float > 0.0

Figure width [inches]

FigHeight, hfig: {None} | float > 0.0

Figure height [inches]

FigDPI: {None} | int > 0 | float > 0.0

Figure resolution in dots per inch

Outputs:
fig: matplotlib.figure.Figure

Figure handle

Versions:
  • 2019-03-06 @ddalle: First version

  • 2020-01-24 @ddalle: Added options checks

cape.tnakit.plot_mpl.plot(xv, yv, *a, **kw)

Plot connected points with many options

Call:
>>> h, kw = plot(xv, yv, *a, **kw)
Inputs:
xv: np.ndarray[float]

Array of values for x-axis

yv: np.ndarray[float]

Array of values for y-axis

Outputs:
h: cape.tnakit.plot_mpl.MPLHandle

Dictionary of plot handles

Versions:
  • 2019-03-01 @ddalle: First (independent) version

  • 2019-12-23 @ddalle: Object-oriented options and output