CartesianAxes¶
- class CartesianAxes(*args, **kwargs)[source]¶
Bases:
_SharedAxes,PlotAxesAxes subclass for plotting in ordinary Cartesian coordinates. Adds the
formatmethod 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', orproj='rectilinear'to axes-creation commands likeadd_axes,add_subplot, andsubplots.- Parameters
*args – Passed to
matplotlib.axes.Axes.aspect (
{'auto', 'equal'}orfloat, optional) – The data aspect ratio. Seeset_aspectfor details.xlabel, ylabel (
str, optional) – The x and y axis labels. Applied withset_xlabelandset_ylabel.xlabel_kw, ylabel_kw (dict-like, optional) – Additional axis label settings applied with
set_xlabelandset_ylabel. See alsolabelpad,labelcolor,labelsize, andlabelweightbelow.xlim, ylim (
2-tupleoffloatsorNone, optional) – The x and y axis data limits. Applied withset_xlimandset_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 theScaleconstructor. For example,xscale='log'applies logarithmic scaling, andxscale=('cutoff', 100, 2)applies aCutoffScale.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 keywordmarginto set both at once.xbounds, ybounds (
2-tupleoffloat, optional) – The x and y axis data bounds within which to draw the spines. For example,xlim=(0, 4)combined withxbounds=(2, 4)will prevent the spines from meeting at the origin. This also appliesxspineloc='bottom'andyspineloc='left'by default if both spines are currently visible.xtickrange, ytickrange (
2-tupleoffloat, optional) – The x and y axis data ranges within which major tick marks are labelled. For example,xlim=(-5, 5)combined withxtickrange=(-1, 1)and a tick interval of 1 will only label the ticks marks at -1, 0, and 1. SeeAutoFormatterfor details.xwraprange, ywraprange (
2-tupleoffloat, 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. SeeAutoFormatterfor details. This can be combined withxtickrangeandytickrangeto 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'}or2-tuple, optional) – The x and y spine locations. Applied withset_position. Propagates toticklocunless 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 fromspinelocby default and propagates toticklabellocunless 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 fromticklocby default and propagates tolabellocandoffsetlocunless specified otherwise.xlabelloc, ylabelloc (
{'b', 't', 'l', 'r', 'bottom', 'top', 'left', 'right'}, optional) – Which x and y axis spines should have axis labels. Inherits fromticklabellocby default (ifticklabellocis 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 fromticklabellocby default (ifticklabellocis 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 keywordtickdirto control both.xticklabeldir, yticklabeldir (
{'in', 'out'}, optional) – Whether to place x and y axis tick label text inside or outside the axes. Propagates toxtickdirandytickdirunless 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 keywordgridto toggle both.xgridminor, ygridminor, gridminor (
bool, default:rc.gridminor=False) – Whether to draw minor gridlines for the x and y axis. Use the keywordgridminorto toggle both.xtickminor, ytickminor, tickminor (
bool, default:rc['tick.minor']=True) – Whether to draw minor ticks on the x and y axes. Use the keywordtickminorto 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 theLocatorconstructor. Can be float, list of float, string, ormatplotlib.ticker.Locatorinstance. Use[],'null', or'none'for no ticks.xlocator_kw, ylocator_kw (dict-like, optional) – Keyword arguments passed to the
matplotlib.ticker.Locatorclass.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 theFormatterconstructor. Can be string, list of strings, ormatplotlib.ticker.Formatterinstance. Use[],'null', or'none'for no labels.xformatter_kw, yformatter_kw (dict-like, optional) – Keyword arguments passed to the
matplotlib.ticker.Formatterclass.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 keywordcolorto 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 keywordgridcolorto 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 totickwidthunless specified otherwise. Use the keywordlinewidthto set both at once.xtickcolor, ytickcolor, tickcolor (
color-spec, default:rc['tick.color']='black') – Color for the x and y axis ticks. Defaults arexcolor,ycolor, andcolorif they were passed. Use the keywordtickcolorto 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 byunits. Use the keywordticklento set both at once.xticklenratio, yticklenratio, ticklenratio (
float, default:rc['tick.lenratio']=0.5) – Relative scaling ofxticklenandyticklenused to determine minor tick lengths. Use the keywordticklenratioto 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 islinewidthif it was passed. If float, units are points. If string, interpreted byunits. Use the keywordtickwidthto set both at once.xtickwidthratio, ytickwidthratio, tickwidthratio (
float, default:rc['tick.widthratio']=0.8) – Relative scaling ofxtickwidthandytickwidthused to determine minor tick widths. Use the keywordtickwidthratioto 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 keywordticklabelpadto set both at once. If float, units are points. If string, interpreted byunits.xticklabelcolor, yticklabelcolor, ticklabelcolor (
color-spec, default:rc['tick.labelcolor']='black') – Color for the x and y tick labels. Defaults arexcolor,ycolor, andcolorif they were passed. Use the keywordticklabelcolorto set both at once.xticklabelsize, yticklabelsize, ticklabelsize (
unit-specorstr, default:rc['tick.labelsize']='medium') – Font size for the x and y tick labels. If float, units are points. If string, interpreted byunits. Use the keywordticklabelsizeto set both at once.xticklabelweight, yticklabelweight, ticklabelweight (
str, default:rc['tick.labelweight']='normal') – Font weight for the x and y tick labels. Use the keywordticklabelweightto 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 byunits.xlabelcolor, ylabelcolor, labelcolor (
color-spec, default:rc['label.color']='black') – Color for the x and y axis labels. Defaults arexcolor,ycolor, andcolorif they were passed. Use the keywordlabelcolorto set both at once.xlabelsize, ylabelsize, labelsize (
unit-specorstr, default:rc['label.size']='medium') – Font size for the x and y axis labels. If float, units are points. If string, interpreted byunits. Use the keywordlabelsizeto set both at once.xlabelweight, ylabelweight, labelweight (
str, default:rc['label.weight']='normal') – Font weight for the x and y axis labels. Use the keywordlabelweightto set both at once.fixticks (
bool, default:False) – Whether to transform the tick locators to aFixedLocator. If your axis ticks are doing weird things (for example, ticks are drawn outside of the axis spine) you can try setting this toTrue.
- Other Parameters
title (
stror sequence, optional) – The axes title. Can optionally be a sequence strings, in which case the title will be selected from the sequence according tonumber.abc (
boolorstror sequence, default:rc.abc=False) – The “a-b-c” subplot label style. Must contain the characteraorA, for example'a.', or'A'. IfTruethen the default style of'a'is used. TheaorAis replaced with the alphabetic character matching thenumber. Ifnumberis 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 simply be selected from the sequence according tonumber.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'abcborder, titleborder (
bool, default:rc['abc.border']=Trueandrc['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']=Falseandrc['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.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 byunits.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 byunits.ltitle, ctitle, rtitle, ultitle, uctitle, urtitle, lltitle, lctitle, lrtitle (
stror sequence, optional) – Shorthands for the below keywords.lefttitle, centertitle, righttitle, upperlefttitle, uppercentertitle, upperrighttitle, lowerlefttitle, lowercentertitle, lowerrighttitle (
stror sequence, optional) – Additional titles in specific positions (seetitlefor details). This works as an alternative to theax.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,rc['axes.facecolor']='white',rc['axes.edgecolor']='black',rc['axes.linewidth']=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 tocontext.rc_kw (dict-like, optional) – An alternative to passing extra keyword arguments. See below.
**kwargs – Remaining keyword arguments are passed to
matplotlib.axes.Axes. Keyword arguments that match the name of anrcsetting are passed toproplot.config.Configurator.contextand used to update the axes. If the setting name has “dots” you can simply omit the dots. For example,abc='A.'modifies therc.abcsetting,titleloc='left'modifies therc['title.loc']setting,gridminor=Truemodifies therc.gridminorsetting, andgridbelow=Truemodifies therc['grid.below']setting. Many of the keyword arguments documented above are internally applied by retrieving settings passed tocontext.
See also
CartesianAxes.format,proplot.axes.Axes,proplot.axes.PlotAxes,proplot.figure.Figure.subplot,proplot.figure.Figure.add_subplotMethods Summary
altx(**kwargs)Add an axes locked to the same location with a distinct x axis.
alty(**kwargs)Add an axes locked to the same location with a distinct y axis.
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.
twinx(**kwargs)Add an axes locked to the same location with a distinct y axis.
twiny(**kwargs)Add an axes locked to the same location with a distinct x axis.