matplotlib.transforms
¶
Matplotlib includes a framework for arbitrary geometric transformations that is used determine the final position of all elements drawn on the canvas.
Transforms are composed into trees of TransformNode
objects
whose actual value depends on their children. When the contents of
children change, their parents are automatically invalidated. The
next time an invalidated transform is accessed, it is recomputed to
reflect those changes. This invalidation/caching approach prevents
unnecessary recomputations of transforms, and contributes to better
interactive performance.
For example, here is a graph of the transform tree used to plot data to the graph:
The framework can be used for both affine and nonaffine transformations. However, for speed, we want use the backend renderers to perform affine transformations whenever possible. Therefore, it is possible to perform just the affine or nonaffine part of a transformation on a set of data. The affine is always assumed to occur after the nonaffine. For any transform:
full transform == nonaffine part + affine part
The backends are not expected to handle nonaffine transformations themselves.

class
matplotlib.transforms.
Affine2D
(matrix=None, **kwargs)[source]¶ Bases:
matplotlib.transforms.Affine2DBase
A mutable 2D affine transformation.
Initialize an Affine transform from a 3x3 numpy float array:
a c e b d f 0 0 1
If matrix is None, initialize with the identity transform.

__init__
(self, matrix=None, **kwargs)[source]¶ Initialize an Affine transform from a 3x3 numpy float array:
a c e b d f 0 0 1
If matrix is None, initialize with the identity transform.

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

static
from_values
(a, b, c, d, e, f)[source]¶ Create a new Affine2D instance from the given values:
a c e b d f 0 0 1
.

get_matrix
(self)[source]¶ Get the underlying transformation matrix as a 3x3 numpy array:
a c e b d f 0 0 1
.

static
identity
()[source]¶ Return a new
Affine2D
object that is the identity transform.Unless this transform will be mutated later on, consider using the faster
IdentityTransform
class instead.

rotate
(self, theta)[source]¶ Add a rotation (in radians) to this transform in place.
Returns self, so this method can easily be chained with more calls to
rotate()
,rotate_deg()
,translate()
andscale()
.

rotate_around
(self, x, y, theta)[source]¶ Add a rotation (in radians) around the point (x, y) in place.
Returns self, so this method can easily be chained with more calls to
rotate()
,rotate_deg()
,translate()
andscale()
.

rotate_deg
(self, degrees)[source]¶ Add a rotation (in degrees) to this transform in place.
Returns self, so this method can easily be chained with more calls to
rotate()
,rotate_deg()
,translate()
andscale()
.

rotate_deg_around
(self, x, y, degrees)[source]¶ Add a rotation (in degrees) around the point (x, y) in place.
Returns self, so this method can easily be chained with more calls to
rotate()
,rotate_deg()
,translate()
andscale()
.

scale
(self, sx, sy=None)[source]¶ Add a scale in place.
If sy is None, the same scale is applied in both the x and ydirections.
Returns self, so this method can easily be chained with more calls to
rotate()
,rotate_deg()
,translate()
andscale()
.

set
(self, other)[source]¶ Set this transformation from the frozen copy of another
Affine2DBase
object.

set_matrix
(self, mtx)[source]¶ Set the underlying transformation matrix from a 3x3 numpy array:
a c e b d f 0 0 1
.

skew
(self, xShear, yShear)[source]¶ Add a skew in place.
xShear and yShear are the shear angles along the x and yaxes, respectively, in radians.
Returns self, so this method can easily be chained with more calls to
rotate()
,rotate_deg()
,translate()
andscale()
.

skew_deg
(self, xShear, yShear)[source]¶ Add a skew in place.
xShear and yShear are the shear angles along the x and yaxes, respectively, in degrees.
Returns self, so this method can easily be chained with more calls to
rotate()
,rotate_deg()
,translate()
andscale()
.

translate
(self, tx, ty)[source]¶ Add a translation in place.
Returns self, so this method can easily be chained with more calls to
rotate()
,rotate_deg()
,translate()
andscale()
.


class
matplotlib.transforms.
Affine2DBase
(*args, **kwargs)[source]¶ Bases:
matplotlib.transforms.AffineBase
The base class of all 2D affine transformations.
2D affine transformations are performed using a 3x3 numpy array:
a c e b d f 0 0 1
This class provides the readonly interface. For a mutable 2D affine transformation, use
Affine2D
.Subclasses of this class will generally only need to override a constructor and
get_matrix()
that generates a custom 3x3 matrix.Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__module__
= 'matplotlib.transforms'¶

frozen
(self)[source]¶ Return a frozen copy of this transform node. The frozen copy will not be updated when its children change. Useful for storing a previously known state of a transform where
copy.deepcopy()
might normally be used.

has_inverse
= True¶

input_dims
= 2¶

inverted
(self)[source]¶ Return the corresponding inverse transformation.
It holds
x == self.inverted().transform(self.transform(x))
.The return value of this method should be treated as temporary. An update to self does not cause a corresponding update to its inverted copy.

property
is_separable
¶ bool(x) > bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

static
matrix_from_values
(a, b, c, d, e, f)[source]¶ [Deprecated] Create a new transformation matrix as a 3x3 numpy array of the form:
a c e b d f 0 0 1
Notes
Deprecated since version 3.2.

output_dims
= 2¶

transform_affine
(self, points)[source]¶ Apply only the affine part of this transformation on the given array of values.
transform(values)
is always equivalent totransform_affine(transform_non_affine(values))
.In nonaffine transformations, this is generally a noop. In affine transformations, this is equivalent to
transform(values)
.Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

class
matplotlib.transforms.
AffineBase
(*args, **kwargs)[source]¶ Bases:
matplotlib.transforms.Transform
The base class of all affine transformations of any number of dimensions.
Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__hash__
= None¶

__init__
(self, *args, **kwargs)[source]¶ Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__module__
= 'matplotlib.transforms'¶

is_affine
= True¶

transform
(self, values)[source]¶ Apply this transformation on the given array of values.
Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

transform_affine
(self, values)[source]¶ Apply only the affine part of this transformation on the given array of values.
transform(values)
is always equivalent totransform_affine(transform_non_affine(values))
.In nonaffine transformations, this is generally a noop. In affine transformations, this is equivalent to
transform(values)
.Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

transform_non_affine
(self, points)[source]¶ Apply only the nonaffine part of this transformation.
transform(values)
is always equivalent totransform_affine(transform_non_affine(values))
.In nonaffine transformations, this is generally equivalent to
transform(values)
. In affine transformations, this is always a noop.Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

transform_path
(self, path)[source]¶ Apply the transform to
Path
path, returning a newPath
.In some cases, this transform may insert curves into the path that began as line segments.

class
matplotlib.transforms.
AffineDeltaTransform
(transform, **kwargs)[source]¶ Bases:
matplotlib.transforms.Affine2DBase
A transform wrapper for transforming displacements between pairs of points.
This class is intended to be used to transform displacements ("position deltas") between pairs of points (e.g., as the
offset_transform
ofCollection
s): given a transformt
such thatt = AffineDeltaTransform(t) + offset
,AffineDeltaTransform
satisfiesAffineDeltaTransform(a  b) == AffineDeltaTransform(a)  AffineDeltaTransform(b)
.This is implemented by forcing the offset components of the transform matrix to zero.
This class is experimental as of 3.3, and the API may change.
Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__init__
(self, transform, **kwargs)[source]¶ Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

class
matplotlib.transforms.
Bbox
(points, **kwargs)[source]¶ Bases:
matplotlib.transforms.BboxBase
A mutable bounding box.
Examples
Create from known bounds
The default constructor takes the boundary "points"
[[xmin, ymin], [xmax, ymax]]
.>>> Bbox([[1, 1], [3, 7]]) Bbox([[1.0, 1.0], [3.0, 7.0]])
Alternatively, a Bbox can be created from the flattened points array, the socalled "extents"
(xmin, ymin, xmax, ymax)
>>> Bbox.from_extents(1, 1, 3, 7) Bbox([[1.0, 1.0], [3.0, 7.0]])
or from the "bounds"
(xmin, ymin, width, height)
.>>> Bbox.from_bounds(1, 1, 2, 6) Bbox([[1.0, 1.0], [3.0, 7.0]])
Create from collections of points
The "empty" object for accumulating Bboxs is the null bbox, which is a standin for the empty set.
>>> Bbox.null() Bbox([[inf, inf], [inf, inf]])
Adding points to the null bbox will give you the bbox of those points.
>>> box = Bbox.null() >>> box.update_from_data_xy([[1, 1]]) >>> box Bbox([[1.0, 1.0], [1.0, 1.0]]) >>> box.update_from_data_xy([[2, 3], [3, 2]], ignore=False) >>> box Bbox([[1.0, 1.0], [3.0, 3.0]])
Setting
ignore=True
is equivalent to starting over from a null bbox.>>> box.update_from_data_xy([[1, 1]], ignore=True) >>> box Bbox([[1.0, 1.0], [1.0, 1.0]])
Warning
It is recommended to always specify
ignore
explicitly. If not, the default value ofignore
can be changed at any time by code with access to your Bbox, for example using the methodignore
.Properties of the ``null`` bbox
Note
The current behavior of
Bbox.null()
may be surprising as it does not have all of the properties of the "empty set", and as such does not behave like a "zero" object in the mathematical sense. We may change that in the future (with a deprecation period).The null bbox is the identity for intersections
>>> Bbox.intersection(Bbox([[1, 1], [3, 7]]), Bbox.null()) Bbox([[1.0, 1.0], [3.0, 7.0]])
except with itself, where it returns the full space.
>>> Bbox.intersection(Bbox.null(), Bbox.null()) Bbox([[inf, inf], [inf, inf]])
A union containing null will always return the full space (not the other set!)
>>> Bbox.union([Bbox([[0, 0], [0, 0]]), Bbox.null()]) Bbox([[inf, inf], [inf, inf]])
Parameters:  pointsndarray
A 2x2 numpy array of the form
[[x0, y0], [x1, y1]]
.

__init__
(self, points, **kwargs)[source]¶ Parameters:  pointsndarray
A 2x2 numpy array of the form
[[x0, y0], [x1, y1]]
.

__module__
= 'matplotlib.transforms'¶

static
from_bounds
(x0, y0, width, height)[source]¶ Create a new
Bbox
from x0, y0, width and height.width and height may be negative.

static
from_extents
(*args)[source]¶ Create a new Bbox from left, bottom, right and top.
The yaxis increases upwards.

get_points
(self)[source]¶ Get the points of the bounding box directly as a numpy array of the form:
[[x0, y0], [x1, y1]]
.

ignore
(self, value)[source]¶ Set whether the existing bounds of the box should be ignored by subsequent calls to
update_from_data_xy()
. valuebool
 When
True
, subsequent calls toupdate_from_data_xy()
will ignore the existing bounds of theBbox
.  When
False
, subsequent calls toupdate_from_data_xy()
will include the existing bounds of theBbox
.
 When

property
intervalx
¶ The pair of x coordinates that define the bounding box.
This is not guaranteed to be sorted from left to right.

property
intervaly
¶ The pair of y coordinates that define the bounding box.
This is not guaranteed to be sorted from bottom to top.

property
minpos
¶

property
minposx
¶

property
minposy
¶

property
p0
¶ The first pair of (x, y) coordinates that define the bounding box.
This is not guaranteed to be the bottomleft corner (for that, use
min
).

property
p1
¶ The second pair of (x, y) coordinates that define the bounding box.
This is not guaranteed to be the topright corner (for that, use
max
).

set_points
(self, points)[source]¶ Set the points of the bounding box directly from a numpy array of the form:
[[x0, y0], [x1, y1]]
. No error checking is performed, as this method is mainly for internal use.

update_from_data_xy
(self, xy, ignore=None, updatex=True, updatey=True)[source]¶ Update the bounds of the
Bbox
based on the passed in data. After updating, the bounds will have positive width and height; x0 and y0 will be the minimal values.Parameters:

update_from_path
(self, path, ignore=None, updatex=True, updatey=True)[source]¶ Update the bounds of the
Bbox
to contain the vertices of the provided path. After updating, the bounds will have positive width and height; x0 and y0 will be the minimal values.Parameters:

property
x0
¶ The first of the pair of x coordinates that define the bounding box.
This is not guaranteed to be less than
x1
(for that, usexmin
).

property
x1
¶ The second of the pair of x coordinates that define the bounding box.
This is not guaranteed to be greater than
x0
(for that, usexmax
).

class
matplotlib.transforms.
BboxBase
(shorthand_name=None)[source]¶ Bases:
matplotlib.transforms.TransformNode
The base class of all bounding boxes.
This class is immutable;
Bbox
is a mutable subclass.The canonical representation is as two points, with no restrictions on their ordering. Convenience properties are provided to get the left, bottom, right and top edges and width and height, but these are not stored explicitly.
Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__module__
= 'matplotlib.transforms'¶

anchored
(self, c, container=None)[source]¶ Return a copy of the
Bbox
shifted to position c within container.Parameters:  c(float, float) or str
May be either:
 A sequence (cx, cy) where cx and cy range from 0 to 1, where 0 is left or bottom and 1 is right or top
 a string:  'C' for centered  'S' for bottomcenter  'SE' for bottomleft  'E' for left  etc.
 container
Bbox
, optional The box within which the
Bbox
is positioned; it defaults to the initialBbox
.

coefs
= {'C': (0.5, 0.5), 'E': (1.0, 0.5), 'N': (0.5, 1.0), 'NE': (1.0, 1.0), 'NW': (0, 1.0), 'S': (0.5, 0), 'SE': (1.0, 0), 'SW': (0, 0), 'W': (0, 0.5)}¶

corners
(self)[source]¶ Return the corners of this rectangle as an array of points.
Specifically, this returns the array
[[x0, y0], [x0, y1], [x1, y0], [x1, y1]]
.

count_contains
(self, vertices)[source]¶ Count the number of vertices contained in the
Bbox
. Any vertices with a nonfinite x or y value are ignored.Parameters:  verticesNx2 Numpy array.

count_overlaps
(self, bboxes)[source]¶ Count the number of bounding boxes that overlap this one.
Parameters:  bboxessequence of
BboxBase
 bboxessequence of

expanded
(self, sw, sh)[source]¶ Construct a
Bbox
by expanding this one around its center by the factors sw and sh.

frozen
(self)[source]¶ The base class for anything that participates in the transform tree and needs to invalidate its parents or be invalidated. This includes classes that are not really transforms, such as bounding boxes, since some transforms depend on bounding boxes to compute their values.

fully_contains
(self, x, y)[source]¶ Return whether
x, y
is in the bounding box, but not on its edge.

fully_overlaps
(self, other)[source]¶ Return whether this bounding box overlaps with the other bounding box, not including the edges.
Parameters:  other
BboxBase
 other

property
height
¶ The (signed) height of the bounding box.

static
intersection
(bbox1, bbox2)[source]¶ Return the intersection of bbox1 and bbox2 if they intersect, or None if they don't.

property
intervalx
¶ The pair of x coordinates that define the bounding box.
This is not guaranteed to be sorted from left to right.

property
intervaly
¶ The pair of y coordinates that define the bounding box.
This is not guaranteed to be sorted from bottom to top.

inverse_transformed
(self, transform)[source]¶ [Deprecated] Construct a
Bbox
by statically transforming this one by the inverse of transform.Notes
Deprecated since version 3.3.

is_affine
= True¶

is_bbox
= True¶

is_unit
(self)[source]¶ [Deprecated] Return whether this is the unit box (from (0, 0) to (1, 1)).
Notes
Deprecated since version 3.2.

property
max
¶ The topright corner of the bounding box.

property
min
¶ The bottomleft corner of the bounding box.

overlaps
(self, other)[source]¶ Return whether this bounding box overlaps with the other bounding box.
Parameters:  other
BboxBase
 other

property
p0
¶ The first pair of (x, y) coordinates that define the bounding box.
This is not guaranteed to be the bottomleft corner (for that, use
min
).

property
p1
¶ The second pair of (x, y) coordinates that define the bounding box.
This is not guaranteed to be the topright corner (for that, use
max
).

rotated
(self, radians)[source]¶ Return the axesaligned bounding box that bounds the result of rotating this
Bbox
by an angle of radians.

shrunk
(self, mx, my)[source]¶ Return a copy of the
Bbox
, shrunk by the factor mx in the x direction and the factor my in the y direction. The lower left corner of the box remains unchanged. Normally mx and my will be less than 1, but this is not enforced.

shrunk_to_aspect
(self, box_aspect, container=None, fig_aspect=1.0)[source]¶ Return a copy of the
Bbox
, shrunk so that it is as large as it can be while having the desired aspect ratio, box_aspect. If the box coordinates are relative (i.e. fractions of a larger box such as a figure) then the physical aspect ratio of that figure is specified with fig_aspect, so that box_aspect can also be given as a ratio of the absolute dimensions, not the relative dimensions.

property
size
¶ The (signed) width and height of the bounding box.

splitx
(self, *args)[source]¶ Return a list of new
Bbox
objects formed by splitting the original one with vertical lines at fractional positions given by args.

splity
(self, *args)[source]¶ Return a list of new
Bbox
objects formed by splitting the original one with horizontal lines at fractional positions given by args.

transformed
(self, transform)[source]¶ Construct a
Bbox
by statically transforming this one by transform.

property
width
¶ The (signed) width of the bounding box.

property
x0
¶ The first of the pair of x coordinates that define the bounding box.
This is not guaranteed to be less than
x1
(for that, usexmin
).

property
x1
¶ The second of the pair of x coordinates that define the bounding box.
This is not guaranteed to be greater than
x0
(for that, usexmax
).

property
xmax
¶ The right edge of the bounding box.

property
xmin
¶ The left edge of the bounding box.

property
y0
¶ The first of the pair of y coordinates that define the bounding box.
This is not guaranteed to be less than
y1
(for that, useymin
).

property
y1
¶ The second of the pair of y coordinates that define the bounding box.
This is not guaranteed to be greater than
y0
(for that, useymax
).

property
ymax
¶ The top edge of the bounding box.

property
ymin
¶ The bottom edge of the bounding box.

class
matplotlib.transforms.
BboxTransform
(boxin, boxout, **kwargs)[source]¶ Bases:
matplotlib.transforms.Affine2DBase
BboxTransform
linearly transforms points from oneBbox
to another.Create a new
BboxTransform
that linearly transforms points from boxin to boxout.
__init__
(self, boxin, boxout, **kwargs)[source]¶ Create a new
BboxTransform
that linearly transforms points from boxin to boxout.

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

is_separable
= True¶


class
matplotlib.transforms.
BboxTransformFrom
(boxin, **kwargs)[source]¶ Bases:
matplotlib.transforms.Affine2DBase
BboxTransformFrom
linearly transforms points from a givenBbox
to the unit bounding box.Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__init__
(self, boxin, **kwargs)[source]¶ Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

is_separable
= True¶

class
matplotlib.transforms.
BboxTransformTo
(boxout, **kwargs)[source]¶ Bases:
matplotlib.transforms.Affine2DBase
BboxTransformTo
is a transformation that linearly transforms points from the unit bounding box to a givenBbox
.Create a new
BboxTransformTo
that linearly transforms points from the unit bounding box to boxout.
__init__
(self, boxout, **kwargs)[source]¶ Create a new
BboxTransformTo
that linearly transforms points from the unit bounding box to boxout.

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

is_separable
= True¶


class
matplotlib.transforms.
BboxTransformToMaxOnly
(boxout, **kwargs)[source]¶ Bases:
matplotlib.transforms.BboxTransformTo
BboxTransformTo
is a transformation that linearly transforms points from the unit bounding box to a givenBbox
with a fixed upper left of (0, 0).Create a new
BboxTransformTo
that linearly transforms points from the unit bounding box to boxout.
__module__
= 'matplotlib.transforms'¶


class
matplotlib.transforms.
BlendedAffine2D
(x_transform, y_transform, **kwargs)[source]¶ Bases:
matplotlib.transforms._BlendedMixin
,matplotlib.transforms.Affine2DBase
A "blended" transform uses one transform for the xdirection, and another transform for the ydirection.
This version is an optimization for the case where both child transforms are of type
Affine2DBase
.Create a new "blended" transform using x_transform to transform the xaxis and y_transform to transform the yaxis.
Both x_transform and y_transform must be 2D affine transforms.
You will generally not call this constructor directly but use the
blended_transform_factory
function instead, which can determine automatically which kind of blended transform to create.
__init__
(self, x_transform, y_transform, **kwargs)[source]¶ Create a new "blended" transform using x_transform to transform the xaxis and y_transform to transform the yaxis.
Both x_transform and y_transform must be 2D affine transforms.
You will generally not call this constructor directly but use the
blended_transform_factory
function instead, which can determine automatically which kind of blended transform to create.

__module__
= 'matplotlib.transforms'¶

is_separable
= True¶


class
matplotlib.transforms.
BlendedGenericTransform
(x_transform, y_transform, **kwargs)[source]¶ Bases:
matplotlib.transforms._BlendedMixin
,matplotlib.transforms.Transform
A "blended" transform uses one transform for the xdirection, and another transform for the ydirection.
This "generic" version can handle any given child transform in the x and ydirections.
Create a new "blended" transform using x_transform to transform the xaxis and y_transform to transform the yaxis.
You will generally not call this constructor directly but use the
blended_transform_factory
function instead, which can determine automatically which kind of blended transform to create.
__init__
(self, x_transform, y_transform, **kwargs)[source]¶ Create a new "blended" transform using x_transform to transform the xaxis and y_transform to transform the yaxis.
You will generally not call this constructor directly but use the
blended_transform_factory
function instead, which can determine automatically which kind of blended transform to create.

__module__
= 'matplotlib.transforms'¶

contains_branch
(self, other)[source]¶ Return whether the given transform is a subtree of this transform.
This routine uses transform equality to identify subtrees, therefore in many situations it is object id which will be used.
For the case where the given transform represents the whole of this transform, returns True.

property
depth
¶ Return the number of transforms which have been chained together to form this Transform instance.
Note
For the special case of a Composite transform, the maximum depth of the two is returned.

frozen
(self)[source]¶ Return a frozen copy of this transform node. The frozen copy will not be updated when its children change. Useful for storing a previously known state of a transform where
copy.deepcopy()
might normally be used.

property
has_inverse
¶

input_dims
= 2¶

inverted
(self)[source]¶ Return the corresponding inverse transformation.
It holds
x == self.inverted().transform(self.transform(x))
.The return value of this method should be treated as temporary. An update to self does not cause a corresponding update to its inverted copy.

property
is_affine
¶

is_separable
= True¶

output_dims
= 2¶

pass_through
= True¶

transform_non_affine
(self, points)[source]¶ Apply only the nonaffine part of this transformation.
transform(values)
is always equivalent totransform_affine(transform_non_affine(values))
.In nonaffine transformations, this is generally equivalent to
transform(values)
. In affine transformations, this is always a noop.Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.


class
matplotlib.transforms.
CompositeAffine2D
(a, b, **kwargs)[source]¶ Bases:
matplotlib.transforms.Affine2DBase
A composite transform formed by applying transform a then transform b.
This version is an optimization that handles the case where both a and b are 2D affines.
Create a new composite transform that is the result of applying
Affine2DBase
a thenAffine2DBase
b.You will generally not call this constructor directly but write
a + b
instead, which will automatically choose the best kind of composite transform instance to create.
__init__
(self, a, b, **kwargs)[source]¶ Create a new composite transform that is the result of applying
Affine2DBase
a thenAffine2DBase
b.You will generally not call this constructor directly but write
a + b
instead, which will automatically choose the best kind of composite transform instance to create.

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

property
depth
¶ Return the number of transforms which have been chained together to form this Transform instance.
Note
For the special case of a Composite transform, the maximum depth of the two is returned.


class
matplotlib.transforms.
CompositeGenericTransform
(a, b, **kwargs)[source]¶ Bases:
matplotlib.transforms.Transform
A composite transform formed by applying transform a then transform b.
This "generic" version can handle any two arbitrary transformations.
Create a new composite transform that is the result of applying transform a then transform b.
You will generally not call this constructor directly but write
a + b
instead, which will automatically choose the best kind of composite transform instance to create.
__hash__
= None¶

__init__
(self, a, b, **kwargs)[source]¶ Create a new composite transform that is the result of applying transform a then transform b.
You will generally not call this constructor directly but write
a + b
instead, which will automatically choose the best kind of composite transform instance to create.

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

property
depth
¶

frozen
(self)[source]¶ Return a frozen copy of this transform node. The frozen copy will not be updated when its children change. Useful for storing a previously known state of a transform where
copy.deepcopy()
might normally be used.

property
has_inverse
¶

inverted
(self)[source]¶ Return the corresponding inverse transformation.
It holds
x == self.inverted().transform(self.transform(x))
.The return value of this method should be treated as temporary. An update to self does not cause a corresponding update to its inverted copy.

property
is_affine
¶

property
is_separable
¶

pass_through
= True¶

transform_affine
(self, points)[source]¶ Apply only the affine part of this transformation on the given array of values.
transform(values)
is always equivalent totransform_affine(transform_non_affine(values))
.In nonaffine transformations, this is generally a noop. In affine transformations, this is equivalent to
transform(values)
.Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

transform_non_affine
(self, points)[source]¶ Apply only the nonaffine part of this transformation.
transform(values)
is always equivalent totransform_affine(transform_non_affine(values))
.In nonaffine transformations, this is generally equivalent to
transform(values)
. In affine transformations, this is always a noop.Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.


class
matplotlib.transforms.
IdentityTransform
(*args, **kwargs)[source]¶ Bases:
matplotlib.transforms.Affine2DBase
A special class that does one thing, the identity transform, in a fast way.
Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

frozen
(self)[source]¶ Return a frozen copy of this transform node. The frozen copy will not be updated when its children change. Useful for storing a previously known state of a transform where
copy.deepcopy()
might normally be used.

inverted
(self)[source]¶ Return the corresponding inverse transformation.
It holds
x == self.inverted().transform(self.transform(x))
.The return value of this method should be treated as temporary. An update to self does not cause a corresponding update to its inverted copy.

transform
(self, points)[source]¶ Apply this transformation on the given array of values.
Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

transform_affine
(self, points)[source]¶ Apply only the affine part of this transformation on the given array of values.
transform(values)
is always equivalent totransform_affine(transform_non_affine(values))
.In nonaffine transformations, this is generally a noop. In affine transformations, this is equivalent to
transform(values)
.Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

transform_non_affine
(self, points)[source]¶ Apply only the nonaffine part of this transformation.
transform(values)
is always equivalent totransform_affine(transform_non_affine(values))
.In nonaffine transformations, this is generally equivalent to
transform(values)
. In affine transformations, this is always a noop.Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

transform_path
(self, path)[source]¶ Apply the transform to
Path
path, returning a newPath
.In some cases, this transform may insert curves into the path that began as line segments.

class
matplotlib.transforms.
LockableBbox
(bbox, x0=None, y0=None, x1=None, y1=None, **kwargs)[source]¶ Bases:
matplotlib.transforms.BboxBase
A
Bbox
where some elements may be locked at certain values.When the child bounding box changes, the bounds of this bbox will update accordingly with the exception of the locked elements.
Parameters:  bbox
Bbox
The child bounding box to wrap.
 x0float or None
The locked value for x0, or None to leave unlocked.
 y0float or None
The locked value for y0, or None to leave unlocked.
 x1float or None
The locked value for x1, or None to leave unlocked.
 y1float or None
The locked value for y1, or None to leave unlocked.

__init__
(self, bbox, x0=None, y0=None, x1=None, y1=None, **kwargs)[source]¶ Parameters:  bbox
Bbox
The child bounding box to wrap.
 x0float or None
The locked value for x0, or None to leave unlocked.
 y0float or None
The locked value for y0, or None to leave unlocked.
 x1float or None
The locked value for x1, or None to leave unlocked.
 y1float or None
The locked value for y1, or None to leave unlocked.
 bbox

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

property
locked_x0
¶ float or None: The value used for the locked x0.

property
locked_x1
¶ float or None: The value used for the locked x1.

property
locked_y0
¶ float or None: The value used for the locked y0.

property
locked_y1
¶ float or None: The value used for the locked y1.
 bbox

class
matplotlib.transforms.
ScaledTranslation
(xt, yt, scale_trans, **kwargs)[source]¶ Bases:
matplotlib.transforms.Affine2DBase
A transformation that translates by xt and yt, after xt and yt have been transformed by scale_trans.
Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__init__
(self, xt, yt, scale_trans, **kwargs)[source]¶ Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

class
matplotlib.transforms.
Transform
(shorthand_name=None)[source]¶ Bases:
matplotlib.transforms.TransformNode
The base class of all
TransformNode
instances that actually perform a transformation.All nonaffine transformations should be subclasses of this class. New affine transformations should be subclasses of
Affine2D
.Subclasses of this class should override the following members (at minimum):
input_dims
output_dims
transform()
inverted()
(if an inverse exists)
The following attributes may be overridden if the default is unsuitable:
is_separable
(defaults to True for 1d > 1d transforms, False otherwise)has_inverse
(defaults to True ifinverted()
is overridden, False otherwise)
If the transform needs to do something nonstandard with
matplotlib.path.Path
objects, such as adding curves where there were once line segments, it should override:Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__add__
(self, other)[source]¶ Compose two transforms together so that self is followed by other.
A + B
returns a transformC
so thatC.transform(x) == B.transform(A.transform(x))
.

classmethod
__init_subclass__
()[source]¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.

__module__
= 'matplotlib.transforms'¶

__sub__
(self, other)[source]¶ Compose self with the inverse of other, cancelling identical terms if any:
# In general: A  B == A + B.inverted() # (but see note regarding frozen transforms below). # If A "ends with" B (i.e. A == A' + B for some A') we can cancel # out B: (A' + B)  B == A' # Likewise, if B "starts with" A (B = A + B'), we can cancel out A: A  (A + B') == B'.inverted() == B'^1
Cancellation (rather than naively returning
A + B.inverted()
) is important for multiple reasons: It avoids floatingpoint inaccuracies when computing the inverse of
B:
B  B
is guaranteed to cancel out exactly (resulting in the identity transform), whereasB + B.inverted()
may differ by a small epsilon. B.inverted()
always returns a frozen transform: if one computesA + B + B.inverted()
and later mutatesB
, thenB.inverted()
won't be updated and the last two terms won't cancel out anymore; on the other hand,A + B  B
will always be equal toA
even ifB
is mutated.
 It avoids floatingpoint inaccuracies when computing the inverse of
B:

contains_branch
(self, other)[source]¶ Return whether the given transform is a subtree of this transform.
This routine uses transform equality to identify subtrees, therefore in many situations it is object id which will be used.
For the case where the given transform represents the whole of this transform, returns True.

contains_branch_seperately
(self, other_transform)[source]¶ Return whether the given branch is a subtree of this transform on each separate dimension.
A common use for this method is to identify if a transform is a blended transform containing an axes' data transform. e.g.:
x_isdata, y_isdata = trans.contains_branch_seperately(ax.transData)

property
depth
¶ Return the number of transforms which have been chained together to form this Transform instance.
Note
For the special case of a Composite transform, the maximum depth of the two is returned.

has_inverse
= False¶ True if this transform has a corresponding inverse transform.

input_dims
= None¶ The number of input dimensions of this transform. Must be overridden (with integers) in the subclass.

inverted
(self)[source]¶ Return the corresponding inverse transformation.
It holds
x == self.inverted().transform(self.transform(x))
.The return value of this method should be treated as temporary. An update to self does not cause a corresponding update to its inverted copy.

is_separable
= False¶ True if this transform is separable in the x and y dimensions.

output_dims
= None¶ The number of output dimensions of this transform. Must be overridden (with integers) in the subclass.

transform
(self, values)[source]¶ Apply this transformation on the given array of values.
Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

transform_affine
(self, values)[source]¶ Apply only the affine part of this transformation on the given array of values.
transform(values)
is always equivalent totransform_affine(transform_non_affine(values))
.In nonaffine transformations, this is generally a noop. In affine transformations, this is equivalent to
transform(values)
.Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

transform_angles
(self, angles, pts, radians=False, pushoff=1e05)[source]¶ Transform a set of angles anchored at specific locations.
Parameters:  angles(N,) arraylike
The angles to transform.
 pts(N, 2) arraylike
The points where the angles are anchored.
 radiansbool, default: False
Whether angles are radians or degrees.
 pushofffloat
For each point in pts and angle in angles, the transformed angle is computed by transforming a segment of length pushoff starting at that point and making that angle relative to the horizontal axis, and measuring the angle between the horizontal axis and the transformed segment.
Returns:  (N,) array

transform_bbox
(self, bbox)[source]¶ Transform the given bounding box.
For smarter transforms including caching (a common requirement in Matplotlib), see
TransformedBbox
.

transform_non_affine
(self, values)[source]¶ Apply only the nonaffine part of this transformation.
transform(values)
is always equivalent totransform_affine(transform_non_affine(values))
.In nonaffine transformations, this is generally equivalent to
transform(values)
. In affine transformations, this is always a noop.Parameters:  valuesarray
The input values as NumPy array of length
input_dims
or shape (N xinput_dims
).
Returns:  array
The output values as NumPy array of length
input_dims
or shape (N xoutput_dims
), depending on the input.

transform_path
(self, path)[source]¶ Apply the transform to
Path
path, returning a newPath
.In some cases, this transform may insert curves into the path that began as line segments.

transform_path_affine
(self, path)[source]¶ Apply the affine part of this transform to
Path
path, returning a newPath
.transform_path(path)
is equivalent totransform_path_affine(transform_path_non_affine(values))
.

transform_path_non_affine
(self, path)[source]¶ Apply the nonaffine part of this transform to
Path
path, returning a newPath
.transform_path(path)
is equivalent totransform_path_affine(transform_path_non_affine(values))
.

transform_point
(self, point)[source]¶ Return a transformed point.
This function is only kept for backcompatibility; the more general
transform
method is capable of transforming both a list of points and a single point.The point is given as a sequence of length
input_dims
. The transformed point is returned as a sequence of lengthoutput_dims
.

class
matplotlib.transforms.
TransformNode
(shorthand_name=None)[source]¶ Bases:
object
The base class for anything that participates in the transform tree and needs to invalidate its parents or be invalidated. This includes classes that are not really transforms, such as bounding boxes, since some transforms depend on bounding boxes to compute their values.
Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

INVALID
= 3¶

INVALID_AFFINE
= 2¶

INVALID_NON_AFFINE
= 1¶

__deepcopy__
(self, *args)¶

__dict__
= mappingproxy({'__module__': 'matplotlib.transforms', '__doc__': '\n The base class for anything that participates in the transform tree\n and needs to invalidate its parents or be invalidated. This includes\n classes that are not really transforms, such as bounding boxes, since some\n transforms depend on bounding boxes to compute their values.\n ', '_gid': 0, 'INVALID_NON_AFFINE': 1, 'INVALID_AFFINE': 2, 'INVALID': 3, 'is_affine': False, 'is_bbox': False, 'pass_through': False, '__init__': <function TransformNode.__init__>, '__getstate__': <function TransformNode.__getstate__>, '__setstate__': <function TransformNode.__setstate__>, '__copy__': <function TransformNode.__copy__>, '__deepcopy__': <function TransformNode.__copy__>, 'invalidate': <function TransformNode.invalidate>, '_invalidate_internal': <function TransformNode._invalidate_internal>, 'set_children': <function TransformNode.set_children>, 'frozen': <function TransformNode.frozen>, '__dict__': <attribute '__dict__' of 'TransformNode' objects>, '__weakref__': <attribute '__weakref__' of 'TransformNode' objects>})¶

__init__
(self, shorthand_name=None)[source]¶ Parameters:  shorthand_namestr
A string representing the "name" of the transform. The name carries no significance other than to improve the readability of
str(transform)
when DEBUG=True.

__module__
= 'matplotlib.transforms'¶

__weakref__
¶ list of weak references to the object (if defined)

frozen
(self)[source]¶ Return a frozen copy of this transform node. The frozen copy will not be updated when its children change. Useful for storing a previously known state of a transform where
copy.deepcopy()
might normally be used.

invalidate
(self)[source]¶ Invalidate this
TransformNode
and triggers an invalidation of its ancestors. Should be called any time the transform changes.

is_affine
= False¶

is_bbox
= False¶

pass_through
= False¶ If pass_through is True, all ancestors will always be invalidated, even if 'self' is already invalid.

class
matplotlib.transforms.
TransformWrapper
(child)[source]¶ Bases:
matplotlib.transforms.Transform
A helper class that holds a single child transform and acts equivalently to it.
This is useful if a node of the transform tree must be replaced at run time with a transform of a different type. This class allows that replacement to correctly trigger invalidation.
TransformWrapper
instances must have the same input and output dimensions during their entire lifetime, so the child transform may only be replaced with another child transform of the same dimensions.child: A
Transform
instance. This child may later be replaced withset()
.
__hash__
= None¶

__init__
(self, child)[source]¶ child: A
Transform
instance. This child may later be replaced withset()
.

__module__
= 'matplotlib.transforms'¶

__str__
(self)¶

frozen
(self)[source]¶ Return a frozen copy of this transform node. The frozen copy will not be updated when its children change. Useful for storing a previously known state of a transform where
copy.deepcopy()
might normally be used.

property
has_inverse
¶

property
is_affine
¶

property
is_separable
¶

pass_through
= True¶


class
matplotlib.transforms.
TransformedBbox
(bbox, transform, **kwargs)[source]¶ Bases:
matplotlib.transforms.BboxBase
A
Bbox
that is automatically transformed by a given transform. When either the child bounding box or transform changes, the bounds of this bbox will update accordingly.Parameters: 
__module__
= 'matplotlib.transforms'¶

__str__
(self)¶


class
matplotlib.transforms.
TransformedPatchPath
(patch)[source]¶ Bases:
matplotlib.transforms.TransformedPath
A
TransformedPatchPath
caches a nonaffine transformed copy of thePatch
. This cached copy is automatically updated when the nonaffine part of the transform or the patch changes.Parameters:  patch
Patch

__module__
= 'matplotlib.transforms'¶
 patch

class
matplotlib.transforms.
TransformedPath
(path, transform)[source]¶ Bases:
matplotlib.transforms.TransformNode
A
TransformedPath
caches a nonaffine transformed copy of thePath
. This cached copy is automatically updated when the nonaffine part of the transform changes.Note
Paths are considered immutable by this class. Any update to the path's vertices/codes will not trigger a transform recomputation.
Parameters: 
__module__
= 'matplotlib.transforms'¶

get_transformed_path_and_affine
(self)[source]¶ Return a copy of the child path, with the nonaffine part of the transform already applied, along with the affine part of the path necessary to complete the transformation.

get_transformed_points_and_affine
(self)[source]¶ Return a copy of the child path, with the nonaffine part of the transform already applied, along with the affine part of the path necessary to complete the transformation. Unlike
get_transformed_path_and_affine()
, no interpolation will be performed.


matplotlib.transforms.
blended_transform_factory
(x_transform, y_transform)[source]¶ Create a new "blended" transform using x_transform to transform the xaxis and y_transform to transform the yaxis.
A faster version of the blended transform is returned for the case where both child transforms are affine.

matplotlib.transforms.
composite_transform_factory
(a, b)[source]¶ Create a new composite transform that is the result of applying transform a then transform b.
Shortcut versions of the blended transform are provided for the case where both child transforms are affine, or one or the other is the identity transform.
Composite transforms may also be created using the '+' operator, e.g.:
c = a + b

matplotlib.transforms.
interval_contains
(interval, val)[source]¶ Check, inclusively, whether an interval includes a given value.
Parameters:  interval(float, float)
The endpoints of the interval.
 valfloat
Value to check is within interval.
Returns:  bool
Whether val is within the interval.

matplotlib.transforms.
interval_contains_open
(interval, val)[source]¶ Check, excluding endpoints, whether an interval includes a given value.
Parameters:  interval(float, float)
The endpoints of the interval.
 valfloat
Value to check is within interval.
Returns:  bool
Whether val is within the interval.

matplotlib.transforms.
nonsingular
(vmin, vmax, expander=0.001, tiny=1e15, increasing=True)[source]¶ Modify the endpoints of a range as needed to avoid singularities.
Parameters:  vmin, vmaxfloat
The initial endpoints.
 expanderfloat, default: 0.001
Fractional amount by which vmin and vmax are expanded if the original interval is too small, based on tiny.
 tinyfloat, default: 1e15
Threshold for the ratio of the interval to the maximum absolute value of its endpoints. If the interval is smaller than this, it will be expanded. This value should be around 1e15 or larger; otherwise the interval will be approaching the double precision resolution limit.
 increasingbool, default: True
If True, swap vmin, vmax if vmin > vmax.
Returns:  vmin, vmaxfloat
Endpoints, expanded and/or swapped if necessary. If either input is inf or NaN, or if both inputs are 0 or very close to zero, it returns expander, expander.