Version 3.0.0
matplotlib
Fork me on GitHub

Table of Contents

Related Topics

spines

matplotlib.spines

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 function:set_position for more information.

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

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

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

  • axes : the Axes instance containing the spine
  • spine_type : a string specifying the spine type
  • path : the path instance used to draw the spine

Valid kwargs 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 unknown
capstyle {'butt', 'round', 'projecting'}
clip_box Bbox
clip_on bool
clip_path [(Path, Transform) | Patch | None]
color color
contains callable
edgecolor color or None or 'auto'
facecolor color or None
figure Figure
fill bool
gid str
hatch {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout bool
joinstyle {'miter', 'round', 'bevel'}
label object
linestyle {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth float or None for default
path_effects AbstractPathEffect
picker None or bool or float 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]

(classmethod) Returns an arc Spine.

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

(staticmethod) Returns a circular Spine.

cla()[source]

Clear the current spine

draw(renderer)[source]

Draw the Patch to the given renderer.

get_bounds()[source]

Get the bounds of the spine.

get_patch_transform()[source]

Return the Transform instance which takes 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.

get_path()[source]

Return the path of this patch

get_position()[source]

get the spine position

get_smart_bounds()[source]

get whether the spine has smart bounds

get_spine_transform()[source]

get the spine transform

get_window_extent(renderer=None)[source]

Get the axes bounding box in display space. Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.

Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.

is_frame_like()[source]

return True if directly on axes frame

This is useful for determining if a spine is the edge of an old style MPL plot. If so, this function will return True.

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

(staticmethod) Returns a linear Spine.

register_axis(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(low, high)[source]

Set the bounds of the spine.

set_color(c)[source]

Set the edgecolor.

Parameters:
c : color or sequence of rgba tuples
.. seealso::
set_facecolor(), set_edgecolor()

For setting the edge or face color individually.

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

set the spine to be arc-like

set_patch_circle(center, radius)[source]

set the spine to be circular

set_patch_line()[source]

set the spine to be linear

set_position(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 specify placing the spine inward.)
  • 'axes' : place the spine at the specified Axes coordinate (from 0.0-1.0).
  • '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(value)[source]

set the spine and associated axis to have smart bounds