You are reading an old version of the documentation (v3.1.1). For the latest version see https://matplotlib.org/stable/api/axes_api.html
Version 3.1.2
matplotlib
Fork me on GitHub

Table of Contents

matplotlib.axes

The Axes class

class matplotlib.axes.Axes(fig, rect, facecolor=None, frameon=True, sharex=None, sharey=None, label='', xscale=None, yscale=None, **kwargs)[source]

Bases: matplotlib.axes._base._AxesBase

The Axes contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system.

The Axes instance supports callbacks through a callbacks attribute which is a CallbackRegistry instance. The events you can connect to are 'xlim_changed' and 'ylim_changed' and the callback will be called with func(ax) where ax is the Axes instance.

Attributes:
dataLim : BBox

The bounding box enclosing all data displayed in the Axes.

viewLim : BBox

The view limits in data coordinates.

Build an axes in a figure.

Parameters:
fig : Figure

The axes is build in the Figure fig.

rect : [left, bottom, width, height]

The axes is build in the rectangle rect. rect is in Figure coordinates.

sharex, sharey : Axes, optional

The x or y axis is shared with the x or y axis in the input Axes.

frameon : bool, optional

True means that the axes frame is visible.

**kwargs

Other optional keyword arguments:

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
alpha float
anchor 2-tuple of floats or {'C', 'SW', 'S', 'SE', ...}
animated bool
aspect {'auto', 'equal'} or num
autoscale_on bool
autoscalex_on bool
autoscaley_on bool
axes_locator Callable[[Axes, Renderer], Bbox]
axisbelow bool or 'line'
clip_box Bbox
clip_on bool
clip_path [(Path, Transform) | Patch | None]
contains callable
facecolor color
fc color
figure Figure
frame_on bool
gid str
in_layout bool
label object
navigate bool
navigate_mode unknown
path_effects AbstractPathEffect
picker None or bool or float or callable
position [left, bottom, width, height] or Bbox
rasterization_zorder float or None
rasterized bool or None
sketch_params (scale: float, length: float, randomness: float)
snap bool or None
title str
transform Transform
url str
visible bool
xbound unknown
xlabel str
xlim (left: float, right: float)
xmargin float greater than -0.5
xscale {"linear", "log", "symlog", "logit", ...}
xticklabels List[str]
xticks list
ybound unknown
ylabel str
ylim (bottom: float, top: float)
ymargin float greater than -0.5
yscale {"linear", "log", "symlog", "logit", ...}
yticklabels List[str]
yticks list
zorder float
Returns:
axes : Axes

The new Axes object.

Subplots

SubplotBase Base class for subplots, which are Axes instances with additional methods to facilitate generating and manipulating a set of Axes within a figure.
subplot_class_factory This makes a new class that inherits from SubplotBase and the given axes_class (which is assumed to be a subclass of axes.Axes).

Plotting

Basic

Axes.plot Plot y versus x as lines and/or markers.
Axes.errorbar Plot y versus x as lines and/or markers with attached errorbars.
Axes.scatter A scatter plot of y vs x with varying marker size and/or color.
Axes.plot_date Plot data that contains dates.
Axes.step Make a step plot.
Axes.loglog Make a plot with log scaling on both the x and y axis.