class matplotlib.spines.Spine(axes, spine_type, path, **kwargs)[source]

Bases: matplotlib.patches.Patch

An axis spine -- the line noting the data area boundaries.

Spines are the lines connecting the axis tick marks and noting the boundaries of the data area. They can be placed at arbitrary positions. See set_position for more information.

The default position is ('outward', 0).

Spines are subclasses of Patch, and inherit much of their behavior.

Spines draw a line, a circle, or an arc depending if set_patch_line, set_patch_circle, or set_patch_arc has been called. Line-like is the default.


The Axes instance containing the spine.


The spine type.


The Path instance used to draw the spine.

Other Parameters:

Valid keyword arguments are:

Property Description
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 or None
animated bool
antialiased or aa unknown
capstyle {'butt', 'round', 'projecting'}
clip_box Bbox
clip_on bool
clip_path Patch or (Path, Transform) or None
color color
contains unknown
edgecolor or ec color or None or 'auto'
facecolor or fc color or None
figure Figure
fill bool
gid str
hatch {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout bool
joinstyle {'miter', 'round', 'bevel'}
label object
linestyle or ls {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw float or None
path_effects AbstractPathEffect
picker None or bool or callable
rasterized bool or None
sketch_params (scale: float, length: float, randomness: float)
snap bool or None
transform Transform
url str
visible bool
zorder float
classmethod arc_spine(axes, spine_type, center, radius, theta1, theta2, **kwargs)[source]

Create and return an arc Spine.

classmethod circular_spine(axes, center, radius, **kwargs)[source]

Create and return a circular Spine.


Clear the current spine.

draw(self, renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

rendererRendererBase subclass.


This method is overridden in the Artist subclasses.


Get the bounds of the spine.


Return the Transform instance mapping patch coordinates to data coordinates.

For example, one may define a patch of a circle which represents a radius of 5 by providing coordinates for a unit circle, and a transform which scales the coordinates (the patch coordinate) by 5.


Return the path of this patch.


Return the spine position.


[Deprecated] Return whether the spine has smart bounds.


Deprecated since version 3.2.


Return the spine transform.

get_window_extent(self, renderer=None)[source]

Return the window extent of the spines in display space, including padding for ticks (but not their labels)

classmethod linear_spine(axes, spine_type, **kwargs)[source]

Create and return a linear Spine.

register_axis(self, axis)[source]

Register an axis.

An axis should be registered with its corresponding spine from the Axes instance. This allows the spine to clear any axis properties when needed.

set_bounds(self, low=None, high=None)[source]

Set the spine bounds.

lowfloat or None, optional

The lower spine bound. Passing None leaves the limit unchanged.

The bounds may also be passed as the tuple (low, high) as the first positional argument.

highfloat or None, optional

The higher spine bound. Passing None leaves the limit unchanged.

set_color(self, c)[source]

Set the edgecolor.



This method does not modify the facecolor (which defaults to "none"), unlike the Patch.set_color method defined in the parent class. Use Patch.set_facecolor to set the facecolor.

set_patch_arc(self, center, radius, theta1, theta2)[source]

Set the spine to be arc-like.

set_patch_circle(self, center, radius)[source]

Set the spine to be circular.


Set the spine to be linear.

set_position(self, position)[source]

Set the position of the spine.

Spine position is specified by a 2 tuple of (position type, amount). The position types are:

  • 'outward': place the spine out from the data area by the specified number of points. (Negative values place the spine inwards.)
  • 'axes': place the spine at the specified Axes coordinate (0 to 1).
  • 'data': place the spine at the specified data coordinate.

Additionally, shorthand notations define a special positions:

  • 'center' -> ('axes', 0.5)
  • 'zero' -> ('data', 0.0)
set_smart_bounds(self, value)[source]

[Deprecated] Set the spine and associated axis to have smart bounds.


Deprecated since version 3.2.