CartesianAxes

class CartesianAxes(*args, **kwargs)[source]

Bases: _SharedAxes, PlotAxes

Axes subclass for plotting in ordinary Cartesian coordinates. Adds the format method and overrides several existing methods.

Important

This is the default axes subclass. It can be specified explicitly by passing proj='cart', proj='cartesian', proj='rect', or proj='rectilinear' to axes-creation commands like add_axes, add_subplot, and subplots.

Parameters:
  • *args – Passed to matplotlib.axes.Axes.

  • aspect ({'auto', 'equal'} or float, optional) – The data aspect ratio. See set_aspect() for details.

  • xlabel, ylabel (str, optional) – The x and y axis labels. Applied with set_xlabel and set_ylabel.

  • xlabel_kw, ylabel_kw (dict-like, optional) – Additional axis label settings applied with set_xlabel and set_ylabel. See also labelpad, labelcolor, labelsize, and labelweight below.

  • xlim, ylim (2-tuple of floats or None, optional) – The x and y axis data limits. Applied with set_xlim() and set_ylim().

  • xmin, ymin (float, optional) – The x and y minimum data limits. Useful if you do not want to set the maximum limits.

  • xmax, ymax (float, optional) – The x and y maximum data limits. Useful if you do not want to set the minimum limits.

  • xreverse, yreverse (bool, optional) – Whether to “reverse” the x and y axis direction. Makes the x and y axes ascend left-to-right and top-to-bottom, respectively.

  • xscale, yscale (scale-spec, optional) – The x and y axis scales. Passed to the Scale constructor. For example, xscale='log' applies logarithmic scaling, and xscale=('cutoff', 100, 2) applies a CutoffScale.

  • xscale_kw, yscale_kw (dict-like, optional) – The x and y axis scale settings. Passed to Scale.

  • xmargin, ymargin, margin (float, default: rc.margin = 0.05) – The default margin between plotted content and the x and y axis spines in axes-relative coordinates. This is useful if you don’t witch to explicitly set axis limits. Use the keyword margin to set both at once.

  • xbounds, ybounds (2-tuple of float, optional) – The x and y axis data bounds within which to draw the spines. For example, xlim=(0, 4) combined with xbounds=(2, 4) will prevent the spines from meeting at the origin. This also applies xspineloc='bottom' and yspineloc='left' by default if both spines are currently visible.

  • xtickrange, ytickrange (2-tuple of float, optional) – The x and y axis data ranges within which major tick marks are labelled. For example, xlim=(-5, 5) combined with xtickrange=(-1, 1) and a tick interval of 1 will only label the ticks marks at -1, 0, and 1. See AutoFormatter for details.

  • xwraprange, ywraprange (2-tuple of float, optional) – The x and y axis data ranges with which major tick mark values are wrapped. For example, xwraprange=(0, 3) causes the values 0 through 9 to be formatted as 0, 1, 2, 0, 1, 2, 0, 1, 2, 0. See AutoFormatter for details. This can be combined with xtickrange and ytickrange to make “stacked” line plots.

  • xloc, yloc (optional) – Shorthands for xspineloc, yspineloc.

  • xspineloc, yspineloc ({'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right', 'both', 'neither', 'none', 'zero', 'center'} or 2-tuple, optional) – The x and y spine locations. Applied with set_position. Propagates to tickloc unless specified otherwise.

  • xtickloc, ytickloc ({'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right', 'both', 'neither', 'none'}, optional) – Which x and y axis spines should have major and minor tick marks. Inherits from spineloc by default and propagates to ticklabelloc unless specified otherwise.

  • xticklabelloc, yticklabelloc ({'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right', 'both', 'neither', 'none'}, optional) – Which x and y axis spines should have major tick labels. Inherits from tickloc by default and propagates to labelloc and offsetloc unless specified otherwise.

  • xlabelloc, ylabelloc ({'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right'}, optional) – Which x and y axis spines should have axis labels. Inherits from ticklabelloc by default (if ticklabelloc is a single side).

  • xoffsetloc, yoffsetloc ({'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right'}, optional) – Which x and y axis spines should have the axis offset indicator. Inherits from ticklabelloc by default (if ticklabelloc is a single side).

  • xtickdir, ytickdir, tickdir ({'out', 'in', 'inout'}, optional) – Direction that major and minor tick marks point for the x and y axis. Use the keyword tickdir to control both.

  • xticklabeldir, yticklabeldir ({'in', 'out'}, optional) – Whether to place x and y axis tick label text inside or outside the axes. Propagates to xtickdir and ytickdir unless specified otherwise.

  • xrotation, yrotation (float, default: 0) – The rotation for x and y axis tick labels. for normal axes, rc['formatter.timerotation'] = 'vertical' for time x axes.

  • xgrid, ygrid, grid (bool, default: rc.grid = True) – Whether to draw major gridlines on the x and y axis. Use the keyword grid to toggle both.

  • xgridminor, ygridminor, gridminor (bool, default: rc.gridminor = False) – Whether to draw minor gridlines for the x and y axis. Use the keyword gridminor to toggle both.

  • xtickminor, ytickminor, tickminor (bool, default: rc['tick.minor'] = True) – Whether to draw minor ticks on the x and y axes. Use the keyword tickminor to toggle both.

  • xticks, yticks (optional) – Aliases for xlocator, ylocator.

  • xlocator, ylocator (locator-spec, optional) – Used to determine the x and y axis tick mark positions. Passed to the Locator constructor. Can be float, list of float, string, or matplotlib.ticker.Locator instance. Use [], 'null', or 'none' for no ticks.

  • xlocator_kw, ylocator_kw (dict-like, optional) – Keyword arguments passed to the matplotlib.ticker.Locator class.

  • xminorticks, yminorticks (optional) – Aliases for xminorlocator, yminorlocator.

  • xminorlocator, yminorlocator (optional) – As for xlocator, ylocator, but for the minor ticks.

  • xminorlocator_kw, yminorlocator_kw – As for xlocator_kw, ylocator_kw, but for the minor locator.

  • xticklabels, yticklabels (optional) – Aliases for xformatter, yformatter.

  • xformatter, yformatter (formatter-spec, optional) – Used to determine the x and y axis tick label string format. Passed to the Formatter constructor. Can be string, list of strings, or matplotlib.ticker.Formatter instance. Use [], 'null', or 'none' for no labels.

  • xformatter_kw, yformatter_kw (dict-like, optional) – Keyword arguments passed to the matplotlib.ticker.Formatter class.

  • xcolor, ycolor, color (color-spec, default: rc['meta.color'] = 'black') – Color for the x and y axis spines, ticks, tick labels, and axis labels. Use the keyword color to set both at once.

  • xgridcolor, ygridcolor, gridcolor (color-spec, default: rc['grid.color'] = 'black') – Color for the x and y axis major and minor gridlines. Use the keyword gridcolor to set both at once.

  • xlinewidth, ylinewidth, linewidth (color-spec, default: rc['meta.width'] = 0.6) – Line width for the x and y axis spines and major ticks. Propagates to tickwidth unless specified otherwise. Use the keyword linewidth to set both at once.

  • xtickcolor, ytickcolor, tickcolor (color-spec, default: rc['tick.color'] = 'black') – Color for the x and y axis ticks. Defaults are xcolor, ycolor, and color if they were passed. Use the keyword tickcolor to set both at once.

  • xticklen, yticklen, ticklen (unit-spec, default: rc['tick.len'] = 4.0) – Major tick lengths for the x and y axis. If float, units are points. If string, interpreted by units. Use the keyword ticklen to set both at once.

  • xticklenratio, yticklenratio, ticklenratio (float, default: rc['tick.lenratio'] = 0.5) – Relative scaling of xticklen and yticklen used to determine minor tick lengths. Use the keyword ticklenratio to set both at once.

  • xtickwidth, ytickwidth, tickwidth, (unit-spec, default: rc['tick.width'] = 0.6) – Major tick widths for the x ans y axis. Default is linewidth if it was passed. If float, units are points. If string, interpreted by units. Use the keyword tickwidth to set both at once.

  • xtickwidthratio, ytickwidthratio, tickwidthratio (float, default: rc['tick.widthratio'] = 0.8) – Relative scaling of xtickwidth and ytickwidth used to determine minor tick widths. Use the keyword tickwidthratio to set both at once.

  • xticklabelpad, yticklabelpad, ticklabelpad (unit-spec, default: rc['tick.labelpad'] = 2.0) – The padding between the x and y axis ticks and tick labels. Use the keyword ticklabelpad to set both at once. If float, units are points. If string, interpreted by units.

  • xticklabelcolor, yticklabelcolor, ticklabelcolor (color-spec, default: rc['tick.labelcolor'] = 'black') – Color for the x and y tick labels. Defaults are xcolor, ycolor, and color if they were passed. Use the keyword ticklabelcolor to set both at once.

  • xticklabelsize, yticklabelsize, ticklabelsize (unit-spec or str, default: rc['tick.labelsize'] = 'medium') – Font size for the x and y tick labels. If float, units are points. If string, interpreted by units. Use the keyword ticklabelsize to set both at once.

  • xticklabelweight, yticklabelweight, ticklabelweight (str, default: rc['tick.labelweight'] = 'normal') – Font weight for the x and y tick labels. Use the keyword ticklabelweight to set both at once.

  • xlabelpad, ylabelpad (unit-spec, default: rc['label.pad'] = 4.0) – The padding between the x and y axis bounding box and the x and y axis labels. If float, units are points. If string, interpreted by units.

  • xlabelcolor, ylabelcolor, labelcolor (color-spec, default: rc['label.color'] = 'black') – Color for the x and y axis labels. Defaults are xcolor, ycolor, and color if they were passed. Use the keyword labelcolor to set both at once.

  • xlabelsize, ylabelsize, labelsize (unit-spec or str, default: rc['label.size'] = 'medium') – Font size for the x and y axis labels. If float, units are points. If string, interpreted by units. Use the keyword labelsize to set both at once.

  • xlabelweight, ylabelweight, labelweight (str, default: rc['label.weight'] = 'normal') – Font weight for the x and y axis labels. Use the keyword labelweight to set both at once.

  • fixticks (bool, default: False) – Whether to transform the tick locators to a FixedLocator. If your axis ticks are doing weird things (for example, ticks are drawn outside of the axis spine) you can try setting this to True.

Other Parameters:
  • title (str or sequence, optional) – The axes title. Can optionally be a sequence strings, in which case the title will be selected from the sequence according to number.

  • abc (bool or str or sequence, default: rc.abc = False) – The “a-b-c” subplot label style. Must contain the character a or A, for example 'a.', or 'A'. If True then the default style of 'a' is used. The a or A is replaced with the alphabetic character matching the number. If number is greater than 26, the characters loop around to a, …, z, aa, …, zz, aaa, …, zzz, etc. Can also be a sequence of strings, in which case the “a-b-c” label will be selected sequentially from the list. For example axs.format(abc = ["X", "Y"]) for a two-panel figure, and axes[3:5].format(abc = ["X", "Y"]) for a two-panel subset of a larger figure.

  • abcloc, titleloc (str, default: rc['abc.loc'] = 'left', rc['title.loc'] = 'center') – Strings indicating the location for the a-b-c label and main title. The following locations are valid:

    Location

    Valid keys

    center above axes

    'center', 'c'

    left above axes

    'left', 'l'

    right above axes

    'right', 'r'

    lower center inside axes

    'lower center', 'lc'

    upper center inside axes

    'upper center', 'uc'

    upper right inside axes

    'upper right', 'ur'

    upper left inside axes

    'upper left', 'ul'

    lower left inside axes

    'lower left', 'll'

    lower right inside axes

    'lower right', 'lr'

    left of y axis

    'outer left', 'ol'

    right of y axis

    'outer right', 'or'

  • abcborder, titleborder (bool, default: rc['abc.border'] = True and rc['title.border'] = True) – Whether to draw a white border around titles and a-b-c labels positioned inside the axes. This can help them stand out on top of artists plotted inside the axes.

  • abcbbox, titlebbox (bool, default: rc['abc.bbox'] = False and rc['title.bbox'] = False) – Whether to draw a white bbox around titles and a-b-c labels positioned inside the axes. This can help them stand out on top of artists plotted inside the axes.

  • abcpad (float or unit-spec, default: rc['abc.pad']) – Horizontal offset to shift the a-b-c label position. Positive values move the label right, negative values move it left. This is separate from abctitlepad, which controls spacing between abc and title when co-located. If float, units are points. If string, interpreted by units.

  • abc_kw, title_kw (dict-like, optional) – Additional settings used to update the a-b-c label and title with text.update().

  • titlepad (float, default: rc['title.pad'] = 5.0) – The padding for the inner and outer titles and a-b-c labels. If float, units are points. If string, interpreted by units.

  • titleabove (bool, default: rc['title.above'] = True) – Whether to try to put outer titles and a-b-c labels above panels, colorbars, or legends that are above the axes.

  • abctitlepad (float, default: rc['abc.titlepad'] = 4.0) – The horizontal padding between a-b-c labels and titles in the same location. If float, units are points. If string, interpreted by units.

  • ltitle, ctitle, rtitle, ultitle, uctitle, urtitle, lltitle, lctitle, lrtitle (str or sequence, :py:class:`optional `) – Shorthands for the below keywords. lefttitle, centertitle, righttitle, upperlefttitle, uppercentertitle, upperrighttitle : str or sequence, optional

  • lowerlefttitle, lowercentertitle, lowerrighttitle (str or sequence, optional) – Additional titles in specific positions (see title for details). This works as an alternative to the ax.format(title='Title', titleloc=loc) workflow and permits adding more than one title-like label for a single axes.

  • a, alpha, fc, facecolor, ec, edgecolor, lw, linewidth, ls, linestyle (**default* *) – rc['axes.alpha'] = None (default: 1.0), rc['axes.facecolor'] = 'white' (default: white), rc['axes.edgecolor'] = 'black' (default: black), rc['axes.linewidth'] = 0.6 (default: 0.6), - Additional settings applied to the background patch, and their shorthands. Their defaults values are the 'axes' properties.

  • rc_mode (int, optional) – The context mode passed to context.

  • rc_kw (dict-like, optional) – An alternative to passing extra keyword arguments. See below.

  • **kwargs – Remaining keyword arguments are passed to matplotlib.axes.Axes.n Keyword arguments that match the name of an rc setting are passed to ultraplot.config.Configurator.context and used to update the axes. If the setting name has “dots” you can simply omit the dots. For example, abc='A.' modifies the rc.abc setting, titleloc='left' modifies the rc['title.loc'] setting, gridminor=True modifies the rc.gridminor setting, and gridbelow=True modifies the rc['grid.below'] setting. Many of the keyword arguments documented above are internally applied by retrieving settings passed to context.

Attributes Summary

name

Methods Summary

altx(**kwargs)

Add an axis locked to the same location with a distinct x axis.

alty(**kwargs)

Add an axis locked to the same location with a distinct y axis.

draw([renderer])

Draw the Artist (and its children) using the given renderer.

dualx(funcscale, **kwargs)

Add an axes locked to the same location whose x axis denotes equivalent coordinates in alternate units.

dualy(funcscale, **kwargs)

Add an axes locked to the same location whose y axis denotes equivalent coordinates in alternate units.

format()

Modify axes limits, axis scales, axis labels, spine locations, tick locations, tick labels, and more.

get_tightbbox(renderer, *args, **kwargs)

Return the tight bounding box of the Axes, including axis and their decorators (xlabel, title, etc).

set(*[, adjustable, agg_filter, alpha, ...])

Set multiple properties at once.

set_xscale(value, **kwargs)

Set the xaxis' scale.

set_yscale(value, **kwargs)

Set the yaxis' scale.

twinx(**kwargs)

Add an axis locked to the same location with a distinct y axis.

twiny(**kwargs)

Add an axis locked to the same location with a distinct x axis.

Attributes Documentation

name = 'rectilinear'

Methods Documentation

altx(**kwargs)[source]

Add an axis locked to the same location with a distinct x axis. This is an alias and arguably more intuitive name for twiny, which generates two x axes with a shared (“twin”) y axes.

Parameters:

**kwargs – Passed to CartesianAxes. Supports all valid format keywords. You can optionally omit the x from keywords beginning with x – for example ax.altx(lim=(0, 10)) is equivalent to ax.altx(xlim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passing loc keywords. For example, ax.altx(loc='bottom') changes the default side from top to bottom.

Returns:

ultraplot.axes.CartesianAxes – The resulting axes.

Note

This enforces the following default settings:

  • Places the old x axis on the bottom and the new x axis on the top.

  • Makes the old top spine invisible and the new bottom, left, and right spines invisible.

  • Adjusts the x axis tick, tick label, and axis label positions according to the visible spine positions.

  • Syncs the old and new y axis limits and scales, and makes the new y axis labels invisible.

alty(**kwargs)[source]

Add an axis locked to the same location with a distinct y axis. This is an alias and arguably more intuitive name for twinx, which generates two y axes with a shared (“twin”) x axes.

Parameters:

**kwargs – Passed to CartesianAxes. Supports all valid format keywords. You can optionally omit the y from keywords beginning with y – for example ax.alty(lim=(0, 10)) is equivalent to ax.alty(ylim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passing loc keywords. For example, ax.alty(loc='left') changes the default side from right to left.

Returns:

ultraplot.axes.CartesianAxes – The resulting axes.

Note

This enforces the following default settings:

  • Places the old y axis on the left and the new y axis on the right.

  • Makes the old right spine invisible and the new left, bottom, and top spines invisible.

  • Adjusts the y axis tick, tick label, and axis label positions according to the visible spine positions.

  • Syncs the old and new x axis limits and scales, and makes the new x axis labels invisible.

draw(renderer=None, *args, **kwargs)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters:

renderer (RendererBase subclass.)

Notes

This method is overridden in the Artist subclasses.

dualx(funcscale, **kwargs)[source]

Add an axes locked to the same location whose x axis denotes equivalent coordinates in alternate units. This is an alternative to matplotlib.axes.Axes.secondary_xaxis with additional convenience features.

Parameters:
  • funcscale (callable(), 2-tuple of callables, or scale-spec) – The scale used to transform units from the parent axis to the secondary axis. This can be a FuncScale itself or a function, (function, function) tuple, or an axis scale specification interpreted by the Scale constructor function, any of which will be used to build a FuncScale and applied to the dual axis (see FuncScale for details).

  • **kwargs – Passed to CartesianAxes. Supports all valid format keywords. You can optionally omit the x from keywords beginning with x – for example ax.altx(lim=(0, 10)) is equivalent to ax.altx(xlim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passing loc keywords. For example, ax.altx(loc='bottom') changes the default side from top to bottom.

Returns:

ultraplot.axes.CartesianAxes – The resulting axes.

Note

This enforces the following default settings:

  • Places the old x axis on the bottom and the new x axis on the top.

  • Makes the old top spine invisible and the new bottom, left, and right spines invisible.

  • Adjusts the x axis tick, tick label, and axis label positions according to the visible spine positions.

  • Syncs the old and new y axis limits and scales, and makes the new y axis labels invisible.

dualy(funcscale, **kwargs)[source]

Add an axes locked to the same location whose y axis denotes equivalent coordinates in alternate units. This is an alternative to matplotlib.axes.Axes.secondary_yaxis with additional convenience features.

Parameters:
  • funcscale (callable(), 2-tuple of callables, or scale-spec) – The scale used to transform units from the parent axis to the secondary axis. This can be a FuncScale itself or a function, (function, function) tuple, or an axis scale specification interpreted by the Scale constructor function, any of which will be used to build a FuncScale and applied to the dual axis (see FuncScale for details).

  • **kwargs – Passed to CartesianAxes. Supports all valid format keywords. You can optionally omit the y from keywords beginning with y – for example ax.alty(lim=(0, 10)) is equivalent to ax.alty(ylim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passing loc keywords. For example, ax.alty(loc='left') changes the default side from right to left.

Returns:

ultraplot.axes.CartesianAxes – The resulting axes.

Note

This enforces the following default settings:

  • Places the old y axis on the left and the new y axis on the right.

  • Makes the old right spine invisible and the new left, bottom, and top spines invisible.

  • Adjusts the y axis tick, tick label, and axis label positions according to the visible spine positions.

  • Syncs the old and new x axis limits and scales, and makes the new x axis labels invisible.

format()[source]

Modify axes limits, axis scales, axis labels, spine locations, tick locations, tick labels, and more.

Parameters:
  • aspect ({'auto', 'equal'} or float, optional) – The data aspect ratio. See set_aspect() for details.

  • xlabel, ylabel (str, optional) – The x and y axis labels. Applied with set_xlabel and set_ylabel.

  • xlabel_kw, ylabel_kw (dict-like, optional) – Additional axis label settings applied with set_xlabel and set_ylabel. See also labelpad, labelcolor, labelsize, and labelweight below.

  • xlim, ylim (2-tuple of floats or None, optional) – The x and y axis data limits. Applied with set_xlim() and set_ylim().

  • xmin, ymin (float, optional) – The x and y minimum data limits. Useful if you do not want to set the maximum limits.

  • xmax, ymax (float, optional) – The x and y maximum data limits. Useful if you do not want to set the minimum limits.

  • xreverse, yreverse (bool, optional) – Whether to “reverse” the x and y axis direction. Makes the x and y axes ascend left-to-right and top-to-bottom, respectively.

  • xscale, yscale (scale-spec, optional) – The x and y axis scales. Passed to the Scale constructor. For example, xscale='log' applies logarithmic scaling, and xscale=('cutoff', 100, 2) applies a CutoffScale.

  • xscale_kw, yscale_kw (dict-like, optional) – The x and y axis scale settings. Passed to Scale.

  • xmargin, ymargin, margin (float, default: rc.margin = 0.05) – The default margin between plotted content and the x and y axis spines in axes-relative coordinates. This is useful if you don’t witch to explicitly set axis limits. Use the keyword margin to set both at once.

  • xbounds, ybounds (2-tuple of float, optional) – The x and y axis data bounds within which to draw the spines. For example, xlim=(0, 4) combined with xbounds=(2, 4) will prevent the spines from meeting at the origin. This also applies xspineloc='bottom' and yspineloc='left' by default if both spines are currently visible.

  • xtickrange, ytickrange (2-tuple of float, optional) – The x and y axis data ranges within which major tick marks are labelled. For example, xlim=(-5, 5) combined with xtickrange=(-1, 1) and a tick interval of 1 will only label the ticks marks at -1, 0, and 1. See AutoFormatter for details.

  • xwraprange, ywraprange (2-tuple of float, optional) – The x and y axis data ranges with which major tick mark values are wrapped. For example, xwraprange=(0, 3) causes the values 0 through 9 to be formatted as 0, 1, 2, 0, 1, 2, 0, 1, 2, 0. See AutoFormatter for details. This can be combined with xtickrange and ytickrange to make “stacked” line plots.

  • xloc, yloc (optional) – Shorthands for xspineloc, yspineloc.

  • xspineloc, yspineloc ({'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right', 'both', 'neither', 'none', 'zero', 'center'} or 2-tuple, optional) – The x and y spine locations. Applied with set_position. Propagates to tickloc unless specified otherwise.

  • xtickloc, ytickloc ({'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right', 'both', 'neither', 'none'}, optional) – Which x and y axis spines should have major and minor tick marks. Inherits from spineloc by default and propagates to ticklabelloc unless specified otherwise.

  • xticklabelloc, yticklabelloc ({'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right', 'both', 'neither', 'none'}, optional) – Which x and y axis spines should have major tick labels. Inherits from tickloc by default and propagates to labelloc and offsetloc unless specified otherwise.

  • xlabelloc, ylabelloc ({'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right'}, optional) – Which x and y axis spines should have axis labels. Inherits from ticklabelloc by default (if ticklabelloc is a single side).

  • xoffsetloc, yoffsetloc ({'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right'}, optional) – Which x and y axis spines should have the axis offset indicator. Inherits from ticklabelloc by default (if ticklabelloc is a single side).

  • xtickdir, ytickdir, tickdir ({'out', 'in', 'inout'}, optional) – Direction that major and minor tick marks point for the x and y axis. Use the keyword tickdir to control both.

  • xticklabeldir, yticklabeldir ({'in', 'out'}, optional) – Whether to place x and y axis tick label text inside or outside the axes. Propagates to xtickdir and ytickdir unless specified otherwise.

  • xrotation, yrotation (float, default: 0) – The rotation for x and y axis tick labels. for normal axes, rc['formatter.timerotation'] = 'vertical' for time x axes.

  • xgrid, ygrid, grid (bool, default: rc.grid = True) – Whether to draw major gridlines on the x and y axis. Use the keyword grid to toggle both.

  • xgridminor, ygridminor, gridminor (bool, default: rc.gridminor = False) – Whether to draw minor gridlines for the x and y axis. Use the keyword gridminor to toggle both.

  • xtickminor, ytickminor, tickminor (bool, default: rc['tick.minor'] = True) – Whether to draw minor ticks on the x and y axes. Use the keyword tickminor to toggle both.

  • xticks, yticks (optional) – Aliases for xlocator, ylocator.

  • xlocator, ylocator (locator-spec, optional) – Used to determine the x and y axis tick mark positions. Passed to the Locator constructor. Can be float, list of float, string, or matplotlib.ticker.Locator instance. Use [], 'null', or 'none' for no ticks.

  • xlocator_kw, ylocator_kw (dict-like, optional) – Keyword arguments passed to the matplotlib.ticker.Locator class.

  • xminorticks, yminorticks (optional) – Aliases for xminorlocator, yminorlocator.

  • xminorlocator, yminorlocator (optional) – As for xlocator, ylocator, but for the minor ticks.

  • xminorlocator_kw, yminorlocator_kw – As for xlocator_kw, ylocator_kw, but for the minor locator.

  • xticklabels, yticklabels (optional) – Aliases for xformatter, yformatter.

  • xformatter, yformatter (formatter-spec, optional) – Used to determine the x and y axis tick label string format. Passed to the Formatter constructor. Can be string, list of strings, or matplotlib.ticker.Formatter instance. Use [], 'null', or 'none' for no labels.

  • xformatter_kw, yformatter_kw (dict-like, optional) – Keyword arguments passed to the matplotlib.ticker.Formatter class.

  • xcolor, ycolor, color (color-spec, default: rc['meta.color'] = 'black') – Color for the x and y axis spines, ticks, tick labels, and axis labels. Use the keyword color to set both at once.

  • xgridcolor, ygridcolor, gridcolor (color-spec, default: rc['grid.color'] = 'black') – Color for the x and y axis major and minor gridlines. Use the keyword gridcolor to set both at once.

  • xlinewidth, ylinewidth, linewidth (color-spec, default: rc['meta.width'] = 0.6) – Line width for the x and y axis spines and major ticks. Propagates to tickwidth unless specified otherwise. Use the keyword linewidth to set both at once.

  • xtickcolor, ytickcolor, tickcolor (color-spec, default: rc['tick.color'] = 'black') – Color for the x and y axis ticks. Defaults are xcolor, ycolor, and color if they were passed. Use the keyword tickcolor to set both at once.

  • xticklen, yticklen, ticklen (unit-spec, default: rc['tick.len'] = 4.0) – Major tick lengths for the x and y axis. If float, units are points. If string, interpreted by units. Use the keyword ticklen to set both at once.

  • xticklenratio, yticklenratio, ticklenratio (float, default: rc['tick.lenratio'] = 0.5) – Relative scaling of xticklen and yticklen used to determine minor tick lengths. Use the keyword ticklenratio to set both at once.

  • xtickwidth, ytickwidth, tickwidth, (unit-spec, default: rc['tick.width'] = 0.6) – Major tick widths for the x ans y axis. Default is linewidth if it was passed. If float, units are points. If string, interpreted by units. Use the keyword tickwidth to set both at once.

  • xtickwidthratio, ytickwidthratio, tickwidthratio (float, default: rc['tick.widthratio'] = 0.8) – Relative scaling of xtickwidth and ytickwidth used to determine minor tick widths. Use the keyword tickwidthratio to set both at once.

  • xticklabelpad, yticklabelpad, ticklabelpad (unit-spec, default: rc['tick.labelpad'] = 2.0) – The padding between the x and y axis ticks and tick labels. Use the keyword ticklabelpad to set both at once. If float, units are points. If string, interpreted by units.

  • xticklabelcolor, yticklabelcolor, ticklabelcolor (color-spec, default: rc['tick.labelcolor'] = 'black') – Color for the x and y tick labels. Defaults are xcolor, ycolor, and color if they were passed. Use the keyword ticklabelcolor to set both at once.

  • xticklabelsize, yticklabelsize, ticklabelsize (unit-spec or str, default: rc['tick.labelsize'] = 'medium') – Font size for the x and y tick labels. If float, units are points. If string, interpreted by units. Use the keyword ticklabelsize to set both at once.

  • xticklabelweight, yticklabelweight, ticklabelweight (str, default: rc['tick.labelweight'] = 'normal') – Font weight for the x and y tick labels. Use the keyword ticklabelweight to set both at once.

  • xlabelpad, ylabelpad (unit-spec, default: rc['label.pad'] = 4.0) – The padding between the x and y axis bounding box and the x and y axis labels. If float, units are points. If string, interpreted by units.

  • xlabelcolor, ylabelcolor, labelcolor (color-spec, default: rc['label.color'] = 'black') – Color for the x and y axis labels. Defaults are xcolor, ycolor, and color if they were passed. Use the keyword labelcolor to set both at once.

  • xlabelsize, ylabelsize, labelsize (unit-spec or str, default: rc['label.size'] = 'medium') – Font size for the x and y axis labels. If float, units are points. If string, interpreted by units. Use the keyword labelsize to set both at once.

  • xlabelweight, ylabelweight, labelweight (str, default: rc['label.weight'] = 'normal') – Font weight for the x and y axis labels. Use the keyword labelweight to set both at once.

  • fixticks (bool, default: False) – Whether to transform the tick locators to a FixedLocator. If your axis ticks are doing weird things (for example, ticks are drawn outside of the axis spine) you can try setting this to True.

Other Parameters:
  • title (str or sequence, optional) – The axes title. Can optionally be a sequence strings, in which case the title will be selected from the sequence according to number.

  • abc (bool or str or sequence, default: rc.abc = False) – The “a-b-c” subplot label style. Must contain the character a or A, for example 'a.', or 'A'. If True then the default style of 'a' is used. The a or A is replaced with the alphabetic character matching the number. If number is greater than 26, the characters loop around to a, …, z, aa, …, zz, aaa, …, zzz, etc. Can also be a sequence of strings, in which case the “a-b-c” label will be selected sequentially from the list. For example axs.format(abc = ["X", "Y"]) for a two-panel figure, and axes[3:5].format(abc = ["X", "Y"]) for a two-panel subset of a larger figure.

  • abcloc, titleloc (str, default: rc['abc.loc'] = 'left', rc['title.loc'] = 'center') – Strings indicating the location for the a-b-c label and main title. The following locations are valid:

    Location

    Valid keys

    center above axes

    'center', 'c'

    left above axes

    'left', 'l'

    right above axes

    'right', 'r'

    lower center inside axes

    'lower center', 'lc'

    upper center inside axes

    'upper center', 'uc'

    upper right inside axes

    'upper right', 'ur'

    upper left inside axes

    'upper left', 'ul'

    lower left inside axes

    'lower left', 'll'

    lower right inside axes

    'lower right', 'lr'

    left of y axis

    'outer left', 'ol'

    right of y axis

    'outer right', 'or'

  • abcborder, titleborder (bool, default: rc['abc.border'] = True and rc['title.border'] = True) – Whether to draw a white border around titles and a-b-c labels positioned inside the axes. This can help them stand out on top of artists plotted inside the axes.

  • abcbbox, titlebbox (bool, default: rc['abc.bbox'] = False and rc['title.bbox'] = False) – Whether to draw a white bbox around titles and a-b-c labels positioned inside the axes. This can help them stand out on top of artists plotted inside the axes.

  • abcpad (float or unit-spec, default: rc['abc.pad']) – Horizontal offset to shift the a-b-c label position. Positive values move the label right, negative values move it left. This is separate from abctitlepad, which controls spacing between abc and title when co-located. If float, units are points. If string, interpreted by units.

  • abc_kw, title_kw (dict-like, optional) – Additional settings used to update the a-b-c label and title with text.update().

  • titlepad (float, default: rc['title.pad'] = 5.0) – The padding for the inner and outer titles and a-b-c labels. If float, units are points. If string, interpreted by units.

  • titleabove (bool, default: rc['title.above'] = True) – Whether to try to put outer titles and a-b-c labels above panels, colorbars, or legends that are above the axes.

  • abctitlepad (float, default: rc['abc.titlepad'] = 4.0) – The horizontal padding between a-b-c labels and titles in the same location. If float, units are points. If string, interpreted by units.

  • ltitle, ctitle, rtitle, ultitle, uctitle, urtitle, lltitle, lctitle, lrtitle (str or sequence, :py:class:`optional `) – Shorthands for the below keywords. lefttitle, centertitle, righttitle, upperlefttitle, uppercentertitle, upperrighttitle : str or sequence, optional

  • lowerlefttitle, lowercentertitle, lowerrighttitle (str or sequence, optional) – Additional titles in specific positions (see title for details). This works as an alternative to the ax.format(title='Title', titleloc=loc) workflow and permits adding more than one title-like label for a single axes.

  • a, alpha, fc, facecolor, ec, edgecolor, lw, linewidth, ls, linestyle (**default* *) – rc['axes.alpha'] = None (default: 1.0), rc['axes.facecolor'] = 'white' (default: white), rc['axes.edgecolor'] = 'black' (default: black), rc['axes.linewidth'] = 0.6 (default: 0.6), - Additional settings applied to the background patch, and their shorthands. Their defaults values are the 'axes' properties.

  • rowlabels, collabels, llabels, tlabels, rlabels, blabels – Aliases for leftlabels and toplabels, and for leftlabels, toplabels, rightlabels, and bottomlabels, respectively.

  • leftlabels, toplabels, rightlabels, bottomlabels (sequence of str, optional) – Labels for the subplots lying along the left, top, right, and bottom edges of the figure. The length of each list must match the number of subplots along the corresponding edge.

  • leftlabelpad, toplabelpad, rightlabelpad, bottomlabelpad (float or unit-spec, default )

  • rc['leftlabel.pad'] = 5.0, rc['toplabel.pad'] = 5.0, rc['rightlabel.pad'] = 5.0, rc['bottomlabel.pad'] = 5.0 – The padding between the labels and the axes content. If float, units are points. If string, interpreted by units.

  • leftlabels_kw, toplabels_kw, rightlabels_kw, bottomlabels_kw (dict-like, optional) – Additional settings used to update the labels with text.update().

  • figtitle – Alias for suptitle.

  • suptitle (str, optional) – The figure “super” title, centered between the left edge of the leftmost subplot and the right edge of the rightmost subplot.

  • suptitlepad (float, default: rc['suptitle.pad'] = 5.0) – The padding between the super title and the axes content. If float, units are points. If string, interpreted by units.

  • suptitle_kw (optional) – Additional settings used to update the super title with text.update().

  • includepanels (bool, default: False) – Whether to include panels when aligning figure “super titles” along the top of the subplot grid and when aligning the spanx x axis labels and spany y axis labels along the sides of the subplot grid.

  • rc_mode (int, optional) – The context mode passed to context.

  • rc_kw (dict-like, optional) – An alternative to passing extra keyword arguments. See below.

  • **kwargs – Keyword arguments that match the name of an rc setting are passed to ultraplot.config.Configurator.context and used to update the axes. If the setting name has “dots” you can simply omit the dots. For example, abc='A.' modifies the rc.abc setting, titleloc='left' modifies the rc['title.loc'] setting, gridminor=True modifies the rc.gridminor setting, and gridbelow=True modifies the rc['grid.below'] setting. Many of the keyword arguments documented above are internally applied by retrieving settings passed to context.

Note

If you plot something with a datetime64, pandas.Timestamp, pandas.DatetimeIndex, datetime.date, datetime.time, or datetime.datetime array as the x or y axis coordinate, the axis ticks and tick labels will be automatically formatted as dates.

get_tightbbox(renderer, *args, **kwargs)[source]

Return the tight bounding box of the Axes, including axis and their decorators (xlabel, title, etc).

Artists that have artist.set_in_layout(False) are not included in the bbox.

Parameters:
  • renderer (RendererBase subclass) – renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer())

  • bbox_extra_artists (list of Artist or None) – List of artists to include in the tight bounding box. If None (default), then all artist children of the Axes are included in the tight bounding box.

  • call_axes_locator (bool, default: True) – If call_axes_locator is False, it does not call the _axes_locator attribute, which is necessary to get the correct bounding box. call_axes_locator=False can be used if the caller is only interested in the relative size of the tightbbox compared to the Axes bbox.

  • for_layout_only (default: False) – The bounding box will not include the x-extent of the title and the xlabel, or the y-extent of the ylabel.

Returns:

BboxBase – Bounding box in figure pixel coordinates.

set(*, adjustable=<UNSET>, agg_filter=<UNSET>, alpha=<UNSET>, anchor=<UNSET>, animated=<UNSET>, aspect=<UNSET>, autoscale_on=<UNSET>, autoscalex_on=<UNSET>, autoscaley_on=<UNSET>, axes_locator=<UNSET>, axisbelow=<UNSET>, box_aspect=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, external=<UNSET>, facecolor=<UNSET>, forward_navigation_events=<UNSET>, frame_on=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, mouseover=<UNSET>, navigate=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, prop_cycle=<UNSET>, rasterization_zorder=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, subplotspec=<UNSET>, title=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, xbound=<UNSET>, xlabel=<UNSET>, xlim=<UNSET>, xmargin=<UNSET>, xscale=<UNSET>, xticklabels=<UNSET>, xticks=<UNSET>, ybound=<UNSET>, ylabel=<UNSET>, ylim=<UNSET>, ymargin=<UNSET>, yscale=<UNSET>, yticklabels=<UNSET>, yticks=<UNSET>, zorder=<UNSET>)

Set multiple properties at once.

Supported properties are

Property

Description

adjustable

{‘box’, ‘datalim’}

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image

alpha

float or None

anchor

(float, float) or {‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, …}

animated

bool

aspect

{‘auto’, ‘equal’} or float

autoscale_on

bool

autoscalex_on

unknown

autoscaley_on

unknown

axes_locator

Callable[[Axes, Renderer], Bbox]

axisbelow

bool or ‘line’

box_aspect

float or None

clip_box

BboxBase or None

clip_on

bool

clip_path

Patch or (Path, Transform) or None

external

unknown

facecolor or fc

:mpltype:`color`

figure

Figure or SubFigure

forward_navigation_events

bool or “auto”

frame_on

bool

gid

str

in_layout

bool

label

object

mouseover

bool

navigate

bool

navigate_mode

unknown

path_effects

list of AbstractPathEffect

picker

None or bool or float or callable

position

[left, bottom, width, height] or Bbox

prop_cycle

Cycler

rasterization_zorder

float or None

rasterized

bool

sketch_params

(scale: float, length: float, randomness: float)

snap

bool or None

subplotspec

unknown

title

str

transform

Transform

url

str

visible

bool

xbound

(lower: float, upper: float)

xlabel

str

xlim

(left: float, right: float)

xmargin

float greater than -0.5

xscale

unknown

xticklabels

unknown

xticks

unknown

ybound

(lower: float, upper: float)

ylabel

str

ylim

(bottom: float, top: float)

ymargin

float greater than -0.5

yscale

unknown

yticklabels

unknown

yticks

unknown

zorder

float

set_xscale(value, **kwargs)[source]

Set the xaxis’ scale.

Parameters:
  • value (str or ScaleBase) – The axis scale type to apply. Valid string values are the names of scale classes (“linear”, “log”, “function”,…). These may be the names of any of the built-in scales or of any custom scales registered using matplotlib.scale.register_scale.

  • **kwargs – If value is a string, keywords are passed to the instantiation method of the respective class.

set_yscale(value, **kwargs)[source]

Set the yaxis’ scale.

Parameters:
  • value (str or ScaleBase) – The axis scale type to apply. Valid string values are the names of scale classes (“linear”, “log”, “function”,…). These may be the names of any of the built-in scales or of any custom scales registered using matplotlib.scale.register_scale.

  • **kwargs – If value is a string, keywords are passed to the instantiation method of the respective class.

twinx(**kwargs)[source]

Add an axis locked to the same location with a distinct y axis. This builds upon matplotlib.axes.Axes.twinx.

Parameters:

**kwargs – Passed to CartesianAxes. Supports all valid format keywords. You can optionally omit the y from keywords beginning with y – for example ax.alty(lim=(0, 10)) is equivalent to ax.alty(ylim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passing loc keywords. For example, ax.alty(loc='left') changes the default side from right to left.

Returns:

ultraplot.axes.CartesianAxes – The resulting axes.

Note

This enforces the following default settings:

  • Places the old y axis on the left and the new y axis on the right.

  • Makes the old right spine invisible and the new left, bottom, and top spines invisible.

  • Adjusts the y axis tick, tick label, and axis label positions according to the visible spine positions.

  • Syncs the old and new x axis limits and scales, and makes the new x axis labels invisible.

twiny(**kwargs)[source]

Add an axis locked to the same location with a distinct x axis. This builds upon matplotlib.axes.Axes.twiny.

Parameters:

**kwargs – Passed to CartesianAxes. Supports all valid format keywords. You can optionally omit the x from keywords beginning with x – for example ax.altx(lim=(0, 10)) is equivalent to ax.altx(xlim=(0, 10)). You can also change the default side for the axis spine, axis tick marks, axis tick labels, and/or axis labels by passing loc keywords. For example, ax.altx(loc='bottom') changes the default side from top to bottom.

Returns:

ultraplot.axes.CartesianAxes – The resulting axes.

Note

This enforces the following default settings:

  • Places the old x axis on the bottom and the new x axis on the top.

  • Makes the old top spine invisible and the new bottom, left, and right spines invisible.

  • Adjusts the x axis tick, tick label, and axis label positions according to the visible spine positions.

  • Syncs the old and new y axis limits and scales, and makes the new y axis labels invisible.