axis_rule
plot.axis_rule
The axis rule a theme declares, applied to a drawn figure.
A theme states who places an axis’s ticks (ticks), where the axis ends relative to them (axis_ends), how far the two scale-bearing spines stand off the plot (spine_offset) and whether they stop at their outer ticks (spine_trim). :func:place and :func:frame carry those statements out over every axes of a figure, and both do nothing under an empty rule, which is what a figure whose study declares no rule gets: its axes stay exactly as its panels drew them.
An axis cannot always have round ticks, a tick at each end and no empty space at once. Which of the three gives way is the rule’s to say and never this module’s: axis_ends: data keeps the limits and lets the outer ticks sit inside them, ticks widens the axis to a tick at both ends, and near widens an end only where the next tick lies within end_tick_reach of the data.
Whatever a panel or a drawer chose stands. An axis with fixed ticks keeps them and its limits, one with declared limits or an image keeps its limits, and a log, categorical or deliberately bare axis is not touched at all.
Attributes
| Name | Description |
|---|---|
| DEFAULT_MAX_TICKS | |
| DEFAULT_REACH | |
| DEFAULT_STEPS | |
| ENDS | |
| EPS | |
| SLOTS | The Theme slots that make up the axis rule: the ones a figure’s auto_format: false switches off together. |
| TICKS |
Functions
| Name | Description |
|---|---|
| boxed | Whether ax draws a closed frame, which has no free spine to stand off or to trim. |
| figure_axes | Every axes of fig: its panels, their twins, and the insets a composite panel opened inside them. |
| frame | Stand the two scale-bearing spines of every open-framed axes of fig off the plot and end them on their outer ticks, as the theme’s rule states, and align the figure’s axis labels where it says so. |
| mend_gridspecs | Give every zero row or column ratio of fig’s gridspecs a width when fig lays out with the constrained or compressed engine, the two that divide by those ratios. |
| place | Place the ticks and the ends of every axis of fig that nobody placed, by the theme’s rule. |
| round_ticks | Round ticks for data on [a, b] drawn in the view [lo, hi], and the limits to draw them in. |
| ruled | Whether ax is a drawn two-dimensional axes carrying scales, which is all an axis rule speaks about. |
| trim_spine | End one scale-bearing spine of ax on the outermost ticks now inside its limits. An axis with fewer than two ticks has nothing to end on and keeps its whole spine. |
boxed
plot.axis_rule.boxed(ax)Whether ax draws a closed frame, which has no free spine to stand off or to trim.
figure_axes
plot.axis_rule.figure_axes(fig)Every axes of fig: its panels, their twins, and the insets a composite panel opened inside them.
frame
plot.axis_rule.frame(fig, rule, *, skip=())Stand the two scale-bearing spines of every open-framed axes of fig off the plot and end them on their outer ticks, as the theme’s rule states, and align the figure’s axis labels where it says so.
Run once the limits and ticks are final, since a trimmed spine describes the ticks standing at that moment. A boxed frame is skipped: it has no free spine, and moving two sides of a closed box opens it.
mend_gridspecs
plot.axis_rule.mend_gridspecs(fig)Give every zero row or column ratio of fig’s gridspecs a width when fig lays out with the constrained or compressed engine, the two that divide by those ratios.
A colour bar on an equal-aspect image inserts zero-height pad rows into its gridspec, and matplotlib’s constrained and compressed engines then raise ZeroDivisionError at draw time. Under any other engine those pad rows are what keeps the bar beside its image at full height, so they stay as drawn.
place
plot.axis_rule.place(fig, rule, *, skip=(), shared=None, names=None)Place the ticks and the ends of every axis of fig that nobody placed, by the theme’s rule.
ticks: round re-places an automatically located axis on round values (:func:round_ticks); native leaves the backend’s locator in charge; declared refuses a figure in which any scale still carries ticks no panel gave, naming every one of them at once. axis_ends then moves the limits of an axis that is still autoscaled. Axes that share a scale, by the backend or by the figure’s share_x/share_y (shared, {"x": [[axes, ...]], "y": [...]}), are placed from their common extent so they stay on one scale. skip holds the id of every axes the rule leaves alone, and names maps an axes’ id to the panel key an error should call it by.
round_ticks
plot.axis_rule.round_ticks(
a,
b,
lo=None,
hi=None,
*,
max_ticks=DEFAULT_MAX_TICKS,
steps=DEFAULT_STEPS,
ends='near',
reach=DEFAULT_REACH,
)Round ticks for data on [a, b] drawn in the view [lo, hi], and the limits to draw them in.
The ticks are the multiples of the finest round step that puts at most max_ticks of them on the axis. ends decides the limits. data keeps the view and places the ticks inside it. ticks takes the multiple at or below a and the one at or above b, so both ends carry a tick however far that widens the axis. near lets an end take that multiple only where it widens the axis by at most reach of the data’s span and keeps the view’s end otherwise, preferring the placement with the most ticks and then the most ends on one, and widening past reach only where the axis would otherwise carry fewer than three ticks.
Where no step fits the budget with two ticks or more, the step that exceeds it by least is taken: one tick too many states the scale, two non-round ticks at the data’s own ends do not.
ruled
plot.axis_rule.ruled(ax)Whether ax is a drawn two-dimensional axes carrying scales, which is all an axis rule speaks about.
trim_spine
plot.axis_rule.trim_spine(ax, name)End one scale-bearing spine of ax on the outermost ticks now inside its limits. An axis with fewer than two ticks has nothing to end on and keeps its whole spine.