matplotlib.axis¶
Table of Contents
Classes for the ticks and x and y axis.
Axis objects¶
- class matplotlib.axis.Axis(axes, pickradius=15)[source]¶
Base class for XAxis and YAxis.
Attributes: - isDefault_labelbool
- axesmatplotlib.axes.Axes
The Axes instance the artist resides in, or None.
- majormatplotlib.axis.Ticker
Determines the major tick positions and their label format.
- minormatplotlib.axis.Ticker
Determines the minor tick positions and their label format.
- callbacksmatplotlib.cbook.CallbackRegistry
- labelText
The axis label.
- labelpadfloat
The distance between the axis label and the tick labels. Defaults to rcParams["axes.labelpad"] (default: 4.0) = 4.
- offsetTextText
A Text object containing the data offset of the ticks (if any).
- pickradiusfloat
The acceptance radius for containment tests. See also Axis.contains.
- majorTickslist of Tick
The major ticks.
- minorTickslist of Tick
The minor ticks.
Parameters: - axesmatplotlib.axes.Axes
The Axes to which the created Axis belongs.
- pickradiusfloat
The acceptance radius for containment tests. See also Axis.contains.
- class matplotlib.axis.XAxis(*args, **kwargs)[source]¶
Parameters: - axesmatplotlib.axes.Axes
The Axes to which the created Axis belongs.
- pickradiusfloat
The acceptance radius for containment tests. See also Axis.contains.
- class matplotlib.axis.YAxis(*args, **kwargs)[source]¶
Parameters: - axesmatplotlib.axes.Axes
The Axes to which the created Axis belongs.
- pickradiusfloat
The acceptance radius for containment tests. See also Axis.contains.
- class matplotlib.axis.Ticker[source]¶
A container for the objects defining tick position and format.
Attributes: - locatormatplotlib.ticker.Locator subclass
Determines the positions of the ticks.
- formattermatplotlib.ticker.Formatter subclass
Determines the format of the tick labels.
| Axis.clear | Clear the axis. |
| Axis.cla | [Deprecated] Clear this axis. |
| Axis.get_scale | Return this Axis' scale (as a str). |
Formatters and Locators¶
| Axis.get_major_formatter | Get the formatter of the major ticker. |
| Axis.get_major_locator | Get the locator of the major ticker. |
| Axis.get_minor_formatter | Get the formatter of the minor ticker. |
| Axis.get_minor_locator | Get the locator of the minor ticker. |
| Axis.set_major_formatter | Set the formatter of the major ticker. |
| Axis.set_major_locator | Set the locator of the major ticker. |
| Axis.set_minor_formatter | Set the formatter of the minor ticker. |
| Axis.set_minor_locator | Set the locator of the minor ticker. |
| Axis.remove_overlapping_locs | If minor ticker locations that overlap with major ticker locations should be trimmed. |
| Axis.get_remove_overlapping_locs | |
| Axis.set_remove_overlapping_locs |
Axis Label¶
| Axis.set_label_coords | Set the coordinates of the label. |
| Axis.set_label_position | Set the label position (top or bottom) |
| Axis.set_label_text | Set the text value of the axis label. |
| Axis.get_label | Return the axis label as a Text instance. |
| Axis.get_label_position | Return the label position (top or bottom) |
| Axis.get_label_text | Get the text of the label. |
Ticks, tick labels and Offset text¶
| Axis.get_major_ticks | Return the list of major Ticks. |
| Axis.get_majorticklabels | Return this Axis' major tick labels, as a list of Text. |
| Axis.get_majorticklines | Return this Axis' major tick lines as a list of Line2Ds. |
| Axis.get_majorticklocs | Return this Axis' major tick locations in data coordinates. |
| Axis.get_minor_ticks | Return the list of minor Ticks. |
| Axis.get_minorticklabels | Return this Axis' minor tick labels, as a list of Text. |
| Axis.get_minorticklines | Return this Axis' minor tick lines as a list of Line2Ds. |
| Axis.get_minorticklocs | Return this Axis' minor tick locations in data coordinates. |
| Axis.get_offset_text | Return the axis offsetText as a Text instance. |
| Axis.get_tick_padding | |
| Axis.get_ticklabels | Get this Axis' tick labels. |
| Axis.get_ticklines | Return this Axis' tick lines as a list of Line2Ds. |
| Axis.get_ticklocs | Return this Axis' tick locations in data coordinates. |
| Axis.get_gridlines | Return this Axis' grid lines as a list of Line2Ds. |
| Axis.grid | Configure the grid lines. |
| Axis.set_tick_params | Set appearance parameters for ticks, ticklabels, and gridlines. |
| Axis.axis_date | Set up axis ticks and labels to treat data along this Axis as dates. |
Data and view intervals¶
| Axis.get_data_interval | Return the Interval instance for this axis data limits. |
| Axis.get_view_interval | Return the view limits (min, max) of this axis. |
| Axis.get_inverted | Return whether this Axis is oriented in the "inverse" direction. |
| Axis.set_data_interval | Set the axis data limits. |
| Axis.set_view_interval | Set the axis view limits. |
| Axis.set_inverted | Set whether this Axis is oriented in the "inverse" direction. |
Rendering helpers¶
| Axis.get_minpos | |
| Axis.get_tick_space | Return the estimated number of ticks that can fit on the axis. |
| Axis.get_ticklabel_extents | Get the extents of the tick labels on either side of the axes. |
| Axis.get_tightbbox | Return a bounding box that encloses the axis. |
Interactive¶
| Axis.contains | Test whether the artist contains the mouse event. |
| Axis.get_pickradius | Return the depth of the axis used by the picker. |
| Axis.set_pickradius | Set the depth of the axis used by the picker. |
Units¶
| Axis.convert_units | |
| Axis.set_units | Set the units for axis. |
| Axis.get_units | Return the units for axis. |
| Axis.update_units | Introspect data for units converter and update the axis.converter instance if necessary. |
XAxis Specific¶
| XAxis.axis_name | Read-only name identifying the axis. |
| XAxis.get_text_heights | Return how much space should be reserved for text above and below the axes, as a pair of floats. |
| XAxis.get_ticks_position | Return the ticks position ("top", "bottom", "default", or "unknown"). |
| XAxis.set_ticks_position | Set the ticks position. |
| XAxis.tick_bottom | Move ticks and ticklabels (if present) to the bottom of the axes. |
| XAxis.tick_top | Move ticks and ticklabels (if present) to the top of the axes. |
YAxis Specific¶
| YAxis.axis_name | Read-only name identifying the axis. | ||
| YAxis.get_text_widths | |||
| YAxis.get_ticks_position | Return the ticks position ("left", "right", "default", or "unknown"). | ||
| YAxis.set_offset_position |
|
||
| YAxis.set_ticks_position | Set the ticks position. | ||
| YAxis.tick_left | Move ticks and ticklabels (if present) to the left of the axes. | ||
| YAxis.tick_right | Move ticks and ticklabels (if present) to the right of the axes. |
Other¶
| Axis.OFFSETTEXTPAD | |
| Axis.axes | The Axes instance the artist resides in, or None. |
| Axis.limit_range_for_scale | |
| Axis.reset_ticks | Re-initialize the major and minor Tick lists. |
| Axis.set_default_intervals | Set the default limits for the axis data and view interval if they have not been not mutated yet. |
Discouraged¶
These methods should be used together with care, calling set_ticks to specify the desired tick locations before calling set_ticklabels to specify a matching series of labels. Calling set_ticks makes a FixedLocator; it's list of locations is then used by set_ticklabels to make an appropriate FuncFormatter.
| Axis.set_ticks | Set this Axis' tick locations. |
| Axis.set_ticklabels | Set the text values of the tick labels. |
Tick objects¶
- class matplotlib.axis.Tick(axes, loc, label=<deprecated parameter>, size=None, width=None, color=None, tickdir=None, pad=None, labelsize=None, labelcolor=None, zorder=None, gridOn=None, tick1On=True, tick2On=True, label1On=True, label2On=False, major=True, labelrotation=0, grid_color=None, grid_linestyle=None, grid_linewidth=None, grid_alpha=None, **kw)[source]¶
Abstract base class for the axis ticks, grid lines and labels.
Ticks mark a position on an Axis. They contain two lines as markers and two labels; one each for the bottom and top positions (in case of an XAxis) or for the left and right positions (in case of a YAxis).
Attributes: bbox is the Bound2D bounding box in display coords of the Axes loc is the tick location in data coords size is the tick size in points
- class matplotlib.axis.XTick(*args, **kwargs)[source]¶
Contains all the Artists needed to make an x tick - the tick line, the label text and the grid line
bbox is the Bound2D bounding box in display coords of the Axes loc is the tick location in data coords size is the tick size in points
- class matplotlib.axis.YTick(*args, **kwargs)[source]¶
Contains all the Artists needed to make a Y tick - the tick line, the label text and the grid line
bbox is the Bound2D bounding box in display coords of the Axes loc is the tick location in data coords size is the tick size in points
| Tick.apply_tickdir | Set tick direction. |
| Tick.get_loc | Return the tick location (data coords) as a scalar. |
| Tick.get_pad | Get the value of the tick label pad in points. |
| Tick.get_pad_pixels | |
| Tick.get_tick_padding | Get the length of the tick outside of the axes. |
| Tick.get_tickdir | |
| Tick.get_view_interval | Return the view limits (min, max) of the axis the tick belongs to. |
| Tick.set_label1 | Set the label1 text. |
| Tick.set_label2 | Set the label2 text. |
| Tick.set_pad | Set the tick label pad in points |
| Tick.update_position | Set the location of tick in data coords with scalar loc. |
