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.
- close()¶
Close the open figure, if any
- Call:
>>> h.close()
- Inputs:
- h:
MPLHandle Matplotlib object handle
- h:
- 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 runh.lines += L.Conversions from single object to
listare handled automatically, and items are only added to the list if not already present. Thus runningsave()several times in a row with the same arguments will not create the illusion of many objects for a given attribute.
- class cape.tnakit.plot_mpl.MPLOpts(_optsdict=None, _warnmode=1, **kw)¶
Options class for all plot methods in
plot_mplmodule- Call:
>>> opts = MPLOpts(**kw)
- Inputs:
- kw:
dict Keyword options to be filtered and mapped
- kw:
- Outputs:
- opts:
plot_mpl.MPLOpts Options from kwargs with defaults applied
- opts:
- 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
- opts:
- 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
- MarginBottom: {
- Outputs:
- kw:
dict Dictionary of options to
axes_adjust_col()
- kw:
- Versions:
2020-01-10
@ddalle: First version2020-01-18
@ddalle: UsingKwargHandler
- axadjust_options()¶
Process options for axes margin adjustment
- Call:
>>> kw = opts.axadjust_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
Trueunless``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
- MarginBottom: {
- Outputs:
“CoverageCDF”: CoverageOptions.Coverage, * 2020-01-08
@ddalle: First version * 2020-01-18@ddalle: UsingKwargHandler
- axadjust_row_options()¶
Process options for axes margin adjustment
- Call:
>>> kw = opts.axadjust_row_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- MarginBottom: {
- Outputs:
- kw:
dict Dictionary of options to
axes_adjust_row()
- kw:
- Versions:
2020-01-10
@ddalle: First version2020-01-18
@ddalle: UsingKwargHandler
- axes_options()¶
Process options for axes handle
- Call:
>>> kw = opts.axes_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- Keys:
- ax, Axes: {
None} |matplotlib.axes._subplots.Axes Handle to existing axes
- AxesOptions: {
None} |dict Options to
AxesSubplot
- ax, Axes: {
- Outputs:
- kw:
dict Dictionary of options to
plt.axes()
- kw:
- Versions:
2019-03-07
@ddalle: First version2019-12-20
@ddalle: Fromtnakit.mpl.mplopts2020-01-17
@ddalle: UsingKwargHandler
- axformat_options()¶
Process options for axes format
- Call:
>>> kw = opts.axformat_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- Density, density: {
- Outputs:
- kw:
dict Dictionary of options to
axes_format()
- kw:
- Versions:
2019-03-07
@jmeeroff: First version2020-01-18
@ddalle: UsingKwargHandler
- contour_options()¶
Process options for contour plots
- Call:
>>> kw = opts.contour_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- Index, i: {
- Outputs:
- kw:
dict Dictionary of options to
contour()
- kw:
- Versions:
2020-03-26
@jmeeroff: First version
- coverage_options()¶
Process options for coverage intervals
- delta_options()¶
Process options for delta plots
- deltalabel_options()¶
Process options for delta labels
- error_options()¶
Process options for error plots
- Call:
>>> kw = opts.error_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- Index, i: {
- Outputs:
- kw:
dict Dictionary of options to
error()
- kw:
- Versions:
2019-03-04
@ddalle: First version2019-12-23
@ddalle: Fromtnakit.mpl.mplopts2020-01-17
@ddalle: UsingKwargHandler
- errorbar_options()¶
Process options for
errorbar()calls- Call:
>>> kw = opts.errorbar_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- ErrorBarOptions, ErrorBarOpts: {
- Outputs:
- kw:
dict Dictionary of options to
errorbar()
- kw:
- Versions:
2019-03-05
@ddalle: First version2019-12-21
@ddalle: Fromtnakit.mpl.mplopts2020-01-17
@ddalle: UsingKwargHandler
- figure_options()¶
Process options specific to Matplotlib figure
- Call:
>>> kw = figure_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- fig, Figure: {
- Outputs:
- kw:
dict Dictionary of options to
plt.figure()
- kw:
- Versions:
2019-03-06
@ddalle: First version2019-12-20
@ddalle: Fromtnakit.mpl.mplopts2020-01-17
@ddalle: UsingKwargHandler
- fillbetween_options()¶
Process options for
fill_between()calls
- font_options()¶
Process global font options
- gauss_options()¶
Process options to gaussian plot curve
- Call:
>>> kw = opts.gauss_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- NGauss, ngauss: {
- Outputs:
- Versions:
2019-03-07
@ddalle: First version2019-12-19
@ddalle: Fromtnakit.mpl.mplopts2020-01-17
@ddalle: UsingKwargHandler
- grid_options()¶
Process options to axes
grid()command- Call:
>>> kw = opts.grid_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- Grid, grid: {
- Outputs:
- kw:
dict Dictionary of options to
grid()
- kw:
- Versions:
2019-03-07
@jmeeroff: First version2019-12-23
@ddalle: Fromtnakit.mpl.mplopts2020-01-17
@ddalle: UsingKwargHandler
- hist_options()¶
Process options for histogram plots
- histlabel_options()¶
Process options to gaussian plot curve
- imshow_options()¶
Process options for image display calls
- Call:
>>> kw = opts.imshow_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- ImageXMin: {
- Outputs:
- kw:
dict Dictionary of options to
imshow()
- kw:
- Versions:
2020-01-09
@ddalle: First version2020-01-18
@ddalle: UsingKwargHandler
- interval_options()¶
Process options for
interval()calls
- intervallabel_options()¶
Process options for interval label calls
- legend_font_options()¶
Process font options for
legend()calls- Call:
>>> kw = opts.legend_font_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- Keys:
- LegendFontOptions: {
None} |dict Options to
FontProperties- FontOptions: {
None} |dict Options to
FontProperties- LegendFontName: {
None} |str Font name (categories like
sans-serifallowed)- 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.
- LegendFontOptions: {
- Outputs:
- kw:
dict Dictionary of options to
errorbar()
- kw:
- Versions:
2020-01-19
@ddalle: First version
- legend_options()¶
Process options for
legend()- Call:
>>> kw = opts.legend_options(kw, kwp={})
- Inputs:
- Keys:
- Outputs:
- Versions:
2019-03-07
@ddalle: First version2019-12-23
@ddalle: Fromtnakit.mpl.mplopts2020-01-98
@ddalle: UsingKwargHandler
- mean_options()¶
Process options plot mean on histogram
- meanlabel_options()¶
Process options to histogram mean labels
- minmax_options()¶
Process options for min/max plots
- Call:
>>> kw = opts.minmax_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- Index, i: {
- Outputs:
- kw:
dict Dictionary of options to
minmax()
- kw:
- Versions:
2019-03-04
@ddalle: First version2019-12-20
@ddalle: Fromtnakit.mpl.mplopts2020-01-17
@ddalle: UsingKwargHandler
- plot_options()¶
Process options to primary plot curve
- Call:
>>> kw = opts.plot_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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()
- Index, i: {
- Outputs:
- Versions:
2019-03-07
@ddalle: First version2019-12-19
@ddalle: Fromtnakit.mpl.mplopts2020-01-17
@ddalle: UsingKwargHandler
- scatter_options()¶
Process options for
scatter()calls
- sigma_options()¶
Process options for
sigma()calls
- sigmalabel_options()¶
Process options for
sigma()labels
- spine_options()¶
Process options for axes “spines”
- Call:
>>> kw = opts.spine_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- Spines: {
- Outputs:
- kw:
dict Dictionary of options to each of four spines
- kw:
- Versions:
2019-03-07
@jmeeroff: First version2019-12-20
@ddalle: Fromtnakit.mpl.mplopts2020-01-20
@ddalle: UsingKwargHandler
- uq_options()¶
Process options for uncertainty quantification plots
- Call:
>>> kw = opts.uq_options()
- Inputs:
- opts:
MPLOpts Options interface
- opts:
- 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
- Index, i: {
- Outputs:
- kw:
dict Dictionary of options to
uq()
- kw:
- Versions:
2019-03-04
@ddalle: First version2019-12-23
@ddalle: Fromtnakit.mpl.mplopts2020-01-17
@ddalle: UsingKwargHandler
- 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
- ax, Axes: {
- Outputs:
- ax:
matplotlib.axes._subplots.AxesSubplot Axes handle
- ax:
- Versions:
2019-03-06
@ddalle: First version2020-01-24
@ddalle: Moved toplot_mpl.mpl
- cape.tnakit.plot_mpl.errorbar(xv, yv, yerr=None, xerr=None, **kw)¶
Call the
errorbar()function with options checks- Call:
>>> h = errorbar(xv, yv, yerr=None, xerr=None, **kw)
- Inputs:
- xv:
np.ndarray Array of independent variable values
- yv:
np.ndarray|float Array of values for center of error bar
- yerr: {
None} |np.ndarray|float Array or constant error bar half-heights; shape(2,N) array for distinct above- and below-widths
- xerr: {
None} |np.ndarray|float Array or constant error bar half-widths; shape(2,N) array for distinct above- and below-widths
- xv:
- Keyword Arguments:
- 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
- ErrorBarOptions, ErrorBarOpts: {
- Outputs:
- h:
matplotlib.container.ErrorbarContainer Errorbar plot handle
- h:
- Versions:
2019-03-04
@ddalle: First version2019-08-22
@ddalle: Renamed fromerrorbar_part()2020-01-24
@ddalle: Moved toplot_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
- fig, Figure: {
- Outputs:
- fig:
matplotlib.figure.Figure Figure handle
- fig:
- Versions:
2019-03-06
@ddalle: First version2020-01-24
@ddalle: Added options checks
- cape.tnakit.plot_mpl.legend(ax=None, **kw)¶
Create/update a legend
- Call:
>>> leg = legend(ax=None, **kw)
- Inputs:
- ax: {
None} |matplotlib.axes._subplots.AxesSubplot Axis handle (default is
plt.gca()
- ax: {
- Keyword Arguments:
- Legend: {
None} |True|False Turn on/off (auto) 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
- LegendOptions: {
None} |dict Options to
plt.legend()- FontOptions: {
None} |dict Options to
FontProperties- LegendFontName: {
None} |str Font name (categories like
sans-serifallowed)- 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.
- Legend: {
- Outputs:
- leg:
matplotlib.legend.Legend Legend handle
- leg:
- Versions:
2019-03-07
@ddalle: First version2019-08-22
@ddalle: FromPart.legend_part()2020-01-27
@ddalle: Fromplot_mpl.legend()
- 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
- xv:
- Outputs:
- h:
cape.tnakit.plot_mpl.MPLHandle Dictionary of plot handles
- h:
- Versions:
2019-03-01
@ddalle: First (independent) version2019-12-23
@ddalle: Object-oriented options and output