XYAxes.format(*, aspect=None, xloc=None, yloc=None, xspineloc=None, yspineloc=None, xtickloc=None, ytickloc=None, fixticks=False, xlabelloc=None, ylabelloc=None, xticklabelloc=None, yticklabelloc=None, xtickdir=None, ytickdir=None, xgrid=None, ygrid=None, xgridminor=None, ygridminor=None, xtickminor=None, ytickminor=None, xticklabeldir=None, yticklabeldir=None, xtickrange=None, ytickrange=None, xreverse=None, yreverse=None, xlabel=None, ylabel=None, xlim=None, ylim=None, xscale=None, yscale=None, xrotation=None, yrotation=None, xformatter=None, yformatter=None, xticklabels=None, yticklabels=None, xticks=None, xminorticks=None, xlocator=None, xminorlocator=None, yticks=None, yminorticks=None, ylocator=None, yminorlocator=None, xbounds=None, ybounds=None, xmargin=None, ymargin=None, xcolor=None, ycolor=None, xticklen=None, yticklen=None, xlabel_kw=None, ylabel_kw=None, xscale_kw=None, yscale_kw=None, xlocator_kw=None, ylocator_kw=None, xformatter_kw=None, yformatter_kw=None, xminorlocator_kw=None, yminorlocator_kw=None, patch_kw=None, **kwargs)[source]

Calls Axes.format and Axes.context, formats the x and y axis labels, tick locations, tick labels, axis scales, spine settings, and more.

  • aspect ({‘auto’, ‘equal’}, optional) – The aspect ratio mode.

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

  • xlabel_kw, ylabel_kw (dict-like, optional) – The x and y axis label settings. Applied with the update method on the Text instance. Options include 'color', 'size', and 'weight'.

  • xlim, ylim ((float or None, float or None), optional) – The x and y axis data limits. Applied with set_xlim and set_ylim.

  • xreverse, yreverse (bool, optional) – Sets whether the x and y axis are oriented in the “reverse” direction. The “normal” direction is increasing to the right for the x axis and to the top for the y axis. The “reverse” direction is increasing to the left for the x axis and to the bottom for the y axis.

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

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

  • xspineloc, yspineloc ({‘both’, ‘bottom’, ‘top’, ‘left’, ‘right’, ‘neither’, ‘center’, ‘zero’}, optional) – The x and y axis spine locations.

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

  • xtickloc, ytickloc ({‘both’, ‘bottom’, ‘top’, ‘left’, ‘right’, ‘neither’}, optional) – Which x and y axis spines should have major and minor tick marks.

  • xtickminor, ytickminor (bool, optional) – Whether to draw minor ticks on the x and y axes.

  • xtickdir, ytickdir ({‘out’, ‘in’, ‘inout’}) – Direction that major and minor tick marks point for the x and y axis.

  • xgrid, ygrid (bool, optional) – Whether to draw major gridlines on the x and y axis.

  • xgridminor, ygridminor (bool, optional) – Whether to draw minor gridlines for the x and y axis.

  • xticklabeldir, yticklabeldir ({‘in’, ‘out’}) – Whether to place x and y axis tick label text inside or outside the axes.

  • xlocator, ylocator (locator spec, optional) – Used to determine the x and y axis tick mark positions. Passed to the Locator constructor.

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

  • xlocator_kw, ylocator_kw (dict-like, optional) – The x and y axis locator settings. Passed to Locator.

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

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

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

  • xformatter, yformatter (formatter spec, optional) – Used to determine the x and y axis tick label string format. Passed to the Formatter constructor. Use [] or 'null' for no ticks.

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

  • xformatter_kw, yformatter_kw (dict-like, optional) – The x and y axis formatter settings. Passed to Formatter.

  • xrotation, yrotation (float, optional) – The rotation for x and y axis tick labels. Default is 0 for normal axes, rc[‘axes.formatter.timerotation’] = 90 for time x axes.

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

  • xmargin, ymargin (float, optional) – The default margin between plotted content and the x and y axis spines. Value is proportional to the width, height of the axes. Use this if you want whitespace between plotted content and the spines, but don’t want to explicitly set xlim or ylim.

  • xbounds, ybounds ((float, float), optional) – The x and y axis data bounds within which to draw the spines. For example, the axis range (0, 4) with bounds (1, 4) will prevent the spines from meeting at the origin.

  • xcolor, ycolor (color-spec, optional) – Color for the x and y axis spines, ticks, tick labels, and axis labels. Default is rc.color = 'k'. Use e.g. ax.format(color='red') to set for both axes.

  • xticklen, yticklen (float or str, optional) – Tick lengths for the x and y axis. Units are interpreted by units, with “points” as the numeric unit. Default is rc.ticklen = 4.0.

    Minor tick lengths are scaled according to rc.ticklenratio = 0.5. Use e.g. ax.format(ticklen=1) to set for both axes.

  • fixticks (bool, optional) – Whether to always transform the tick locators to a FixedLocator instance. Default is False. If your axis ticks are doing weird things (for example, ticks drawn outside of the axis spine), try setting this to True.

  • patch_kw (dict-like, optional) – Keyword arguments used to update the background patch object. You can use this, for example, to set background hatching with patch_kw={'hatch':'xxx'}.

  • **kwargs – Passed to Axes.format and Axes.context.


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.