# matplotlib.projections¶

class matplotlib.projections.ProjectionRegistry[source]

Bases: object

A mapping of registered projection names to projection classes.

get_projection_class(self, name)[source]

Get a projection class from its name.

get_projection_names(self)[source]

Return the names of all projections currently registered.

register(self, *projections)[source]

Register a new set of projections.

matplotlib.projections.get_projection_class(projection=None)[source]

Get a projection class from its name.

If projection is None, a standard rectilinear projection is returned.

matplotlib.projections.get_projection_names()

Return the names of all projections currently registered.

matplotlib.projections.register_projection(cls)[source]

# matplotlib.projections.polar¶

class matplotlib.projections.polar.InvertedPolarTransform(axis=None, use_rmin=True, _apply_theta_transforms=True)[source]

The inverse of the polar transform, mapping Cartesian coordinate space x and y back to theta and r.

Parameters: shorthand_namestrA string representing the "name" of the transform. The name carries no significance other than to improve the readability of str(transform) when DEBUG=True.
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.

output_dims = 2
transform_non_affine(self, xy)[source]

Apply only the non-affine part of this transformation.

transform(values) is always equivalent to transform_affine(transform_non_affine(values)).

In non-affine transformations, this is generally equivalent to transform(values). In affine transformations, this is always a no-op.

Parameters: valuesarrayThe input values as NumPy array of length input_dims or shape (N x input_dims). arrayThe output values as NumPy array of length input_dims or shape (N x output_dims), depending on the input.
class matplotlib.projections.polar.PolarAffine(scale_transform, limits)[source]

The affine part of the polar projection. Scales the output so that maximum radius rests on the edge of the axes circle.

limits is the view limit of the data. The only part of its bounds that is used is the y limits (for the radius limits). The theta range is handled by the non-affine transform.

get_matrix(self)[source]

Get the matrix for the affine part of this transform.

class matplotlib.projections.polar.PolarAxes(*args, theta_offset=0, theta_direction=1, rlabel_position=22.5, **kwargs)[source]

Bases: matplotlib.axes._axes.Axes

A polar graph projection, where the input dimensions are theta, r.

Theta starts pointing east and goes anti-clockwise.

Build an axes in a figure.

Parameters:
figFigure

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, shareyAxes, optional

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

frameonbool, default: True

Whether the axes frame is visible.

box_aspectNone, or a number, optional

Sets the aspect of the axes box. See set_box_aspect for details.

**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 or None
anchor 2-tuple of floats or {'C', 'SW', 'S', 'SE', ...}
animated bool
aspect {'auto'} or num
autoscale_on bool
autoscalex_on bool
autoscaley_on bool
axes_locator Callable[[Axes, Renderer], Bbox]
axisbelow bool or 'line'
box_aspect None, or a number
clip_box Bbox
clip_on bool
clip_path Patch or (Path, Transform) or None
contains unknown
facecolor or 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 callable
position [left, bottom, width, height] or Bbox
prop_cycle unknown
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 (bottom: float, top: float)
xmargin float greater than -0.5
xscale {"linear", "log", "symlog", "logit", ...}
xticklabels unknown
xticks unknown
ybound unknown
ylabel str
ylim (bottom: float, top: float)
ymargin float greater than -0.5
yscale {"linear", "log", "symlog", "logit", ...}
yticklabels unknown
yticks unknown
zorder float
Returns:
Axes

The new Axes object.

class InvertedPolarTransform(axis=None, use_rmin=True, _apply_theta_transforms=True)

The inverse of the polar transform, mapping Cartesian coordinate space x and y back to theta and r.

Parameters: shorthand_namestrA string representing the "name" of the transform. The name carries no significance other than to improve the readability of str(transform) when DEBUG=True.
has_inverse = True
input_dims = 2
inverted(self)

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.

output_dims = 2
transform_non_affine(self, xy)

Apply only the non-affine part of this transformation.

transform(values) is always equivalent to transform_affine(transform_non_affine(values)).

In non-affine transformations, this is generally equivalent to transform(values). In affine transformations, this is always a no-op.

Parameters: valuesarrayThe input values as NumPy array of length input_dims or shape (N x input_dims). arrayThe output values as NumPy array of length input_dims or shape (N x output_dims), depending on the input.
class PolarAffine(scale_transform, limits)

The affine part of the polar projection. Scales the output so that maximum radius rests on the edge of the axes circle.

limits is the view limit of the data. The only part of its bounds that is used is the y limits (for the radius limits). The theta range is handled by the non-affine transform.

get_matrix(self)

Get the matrix for the affine part of this transform.

class PolarTransform(axis=None, use_rmin=True, _apply_theta_transforms=True)

The base polar transform. This handles projection theta and r into Cartesian coordinate space x and y, but does not perform the ultimate affine transformation into the correct position.

Parameters: shorthand_namestrA string representing the "name" of the transform. The name carries no significance other than to improve the readability of str(transform) when DEBUG=True.
has_inverse = True
input_dims = 2
inverted(self)

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.

output_dims = 2
transform_non_affine(self, tr)

Apply only the non-affine part of this transformation.

transform(values) is always equivalent to transform_affine(transform_non_affine(values)).

In non-affine transformations, this is generally equivalent to transform(values). In affine transformations, this is always a no-op.

Parameters: valuesarrayThe input values as NumPy array of length input_dims or shape (N x input_dims). arrayThe output values as NumPy array of length input_dims or shape (N x output_dims), depending on the input.
transform_path_non_affine(self, path)

Apply the non-affine part of this transform to Path path, returning a new Path.

transform_path(path) is equivalent to transform_path_affine(transform_path_non_affine(values)).

class RadialLocator(base, axes=None)

Ensures that all ticks are strictly positive. For all other tasks, it delegates to the base Locator (which may be different depending on the scale of the r-axis.

autoscale(self)

[Deprecated]

Notes

Deprecated since version 3.2:

nonsingular(self, vmin, vmax)

Adjust a range as needed to avoid singularities.

This method gets called during autoscaling, with (v0, v1) set to the data limits on the axes if the axes contains any data, or (-inf, +inf) if not.

• If v0 == v1 (possibly up to some floating point slop), this method returns an expanded interval around this value.
• If (v0, v1) == (-inf, +inf), this method returns appropriate default view limits.
• Otherwise, (v0, v1) is returned without modification.
pan(self, numsteps)

[Deprecated]

Notes

Deprecated since version 3.3:

refresh(self)

[Deprecated]

Notes

Deprecated since version 3.3:

view_limits(self, vmin, vmax)

Select a scale for the range from vmin to vmax.

Subclasses should override this method to change locator behaviour.

zoom(self, direction)

[Deprecated]

Notes

Deprecated since version 3.3:

class ThetaFormatter

Used to format the theta tick labels. Converts the native unit of radians into degrees and adds a degree symbol.

class ThetaLocator(base)

Used to locate theta ticks.

This will work the same as the base locator except in the case that the view spans the entire circle. In such cases, the previously used default locations of every 45 degrees are returned.

autoscale(self)

[Deprecated]

Notes

Deprecated since version 3.2:

pan(self, numsteps)

[Deprecated]

Notes

Deprecated since version 3.3:

refresh(self)

[Deprecated] Refresh internal information based on current limits.

Notes

Deprecated since version 3.3.

set_axis(self, axis)
view_limits(self, vmin, vmax)

Select a scale for the range from vmin to vmax.

Subclasses should override this method to change locator behaviour.

zoom(self, direction)

[Deprecated]

Notes

Deprecated since version 3.3:

can_pan(self)[source]

Return True if this axes supports the pan/zoom button functionality.

For polar axes, this is slightly misleading. Both panning and zooming are performed by the same button. Panning is performed in azimuth while zooming is done along the radial.

can_zoom(self)[source]

Return True if this axes supports the zoom box button functionality.

Polar axes do not support zoom boxes.

cla(self)[source]

Clear the current axes.

drag_pan(self, button, key, x, y)[source]

Called when the mouse moves during a pan operation.

Parameters: buttonMouseButtonThe pressed mouse button. keystr or NoneThe pressed key, if any. x, yfloatThe mouse coordinates in display coords.

Notes

This is intended to be overridden by new projection types.

draw(self, renderer, *args, **kwargs)[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).

Parameters: rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

end_pan(self)[source]

Called when a pan operation completes (when the mouse button is up.)

Notes

This is intended to be overridden by new projection types.

format_coord(self, theta, r)[source]

Return a format string formatting the x, y coordinates.

get_data_ratio(self)[source]

Return the aspect ratio of the data itself. For a polar plot, this should always be 1.0

get_rlabel_position(self)[source]
Returns: floatThe theta position of the radius labels in degrees.
get_rmax(self)[source]
get_rmin(self)[source]
get_rorigin(self)[source]
Returns: float
get_rsign(self)[source]
get_theta_direction(self)[source]

Get the direction in which theta increases.

-1:
Theta increases in the clockwise direction
1:
Theta increases in the counterclockwise direction
get_theta_offset(self)[source]

Get the offset for the location of 0 in radians.

get_thetamax(self)[source]

Return the maximum theta limit in degrees.

get_thetamin(self)[source]

Get the minimum theta limit in degrees.

get_xaxis_text1_transform(self, pad)[source]
Returns: transformTransformThe transform used for drawing x-axis labels, which will add pad_points of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis corrdinates valign{'center', 'top', 'bottom', 'baseline', 'center_baseline'}The text vertical alignment. halign{'center', 'left', 'right'}The text horizontal alignment.

Notes

This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

get_xaxis_text2_transform(self, pad)[source]
Returns: transformTransformThe transform used for drawing secondary x-axis labels, which will add pad_points of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis corrdinates valign{'center', 'top', 'bottom', 'baseline', 'center_baseline'}The text vertical alignment. halign{'center', 'left', 'right'}The text horizontal alignment.

Notes

This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

get_xaxis_transform(self, which='grid')[source]

Get the transformation used for drawing x-axis labels, ticks and gridlines. The x-direction is in data coordinates and the y-direction is in axis coordinates.

Note

This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

get_yaxis_text1_transform(self, pad)[source]
Returns: transformTransformThe transform used for drawing y-axis labels, which will add pad_points of padding (in points) between the axes and the label. The x-direction is in axis coordinates and the y-direction is in data corrdinates valign{'center', 'top', 'bottom', 'baseline', 'center_baseline'}The text vertical alignment. halign{'center', 'left', 'right'}The text horizontal alignment.

Notes

This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

get_yaxis_text2_transform(self, pad)[source]
Returns: transformTransformThe transform used for drawing secondart y-axis labels, which will add pad_points of padding (in points) between the axes and the label. The x-direction is in axis coordinates and the y-direction is in data corrdinates valign{'center', 'top', 'bottom', 'baseline', 'center_baseline'}The text vertical alignment. halign{'center', 'left', 'right'}The text horizontal alignment.

Notes

This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

get_yaxis_transform(self, which='grid')[source]

Get the transformation used for drawing y-axis labels, ticks and gridlines. The x-direction is in axis coordinates and the y-direction is in data coordinates.

Note

This transformation is primarily used by the Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

name = 'polar'
set_rgrids(self, radii, labels=None, angle=None, fmt=None, **kwargs)[source]

Set the radial gridlines on a polar plot.

Parameters: radiituple with floatsThe radii for the radial gridlines labelstuple with strings or NoneThe labels to use at each radial gridline. The matplotlib.ticker.ScalarFormatter will be used if None. anglefloatThe angular position of the radius labels in degrees. fmtstr or NoneFormat string used in matplotlib.ticker.FormatStrFormatter. For example '%f'. lineslist of lines.Line2DThe radial gridlines. labelslist of text.TextThe tick labels. **kwargskwargs are optional Text properties for the labels.
set_rlabel_position(self, value)[source]

Update the theta position of the radius labels.

Parameters: valuenumberThe angular position of the radius labels in degrees.
set_rlim(self, bottom=None, top=None, emit=True, auto=False, **kwargs)[source]
set_rmax(self, rmax)[source]

Parameters: rmaxfloat
set_rmin(self, rmin)[source]

Parameters: rminfloat
set_rorigin(self, rorigin)[source]

Parameters: roriginfloat
set_rscale(self, *args, **kwargs)[source]
set_rticks(self, *args, **kwargs)[source]
set_theta_direction(self, direction)[source]

Set the direction in which theta increases.

clockwise, -1:
Theta increases in the clockwise direction
counterclockwise, anticlockwise, 1:
Theta increases in the counterclockwise direction
set_theta_offset(self, offset)[source]

Set the offset for the location of 0 in radians.

set_theta_zero_location(self, loc, offset=0.0)[source]

Set the location of theta's zero.

This simply calls set_theta_offset with the correct value in radians.

Parameters: locstrMay be one of "N", "NW", "W", "SW", "S", "SE", "E", or "NE". offsetfloat, default: 0An offset in degrees to apply from the specified loc. Note: this offset is always applied counter-clockwise regardless of the direction setting.
set_thetagrids(self, angles, labels=None, fmt=None, **kwargs)[source]

Set the theta gridlines in a polar plot.

Parameters: anglestuple with floats, degreesThe angles of the theta gridlines. labelstuple with strings or NoneThe labels to use at each theta gridline. The projections.polar.ThetaFormatter will be used if None. fmtstr or NoneFormat string used in matplotlib.ticker.FormatStrFormatter. For example '%f'. Note that the angle that is used is in radians. lineslist of lines.Line2DThe theta gridlines. labelslist of text.TextThe tick labels. **kwargskwargs are optional Text properties for the labels.
set_thetalim(self, *args, **kwargs)[source]

Set the minimum and maximum theta values.

Can take the following signatures:

• set_thetalim(minval, maxval): Set the limits in radians.
• set_thetalim(thetamin=minval, thetamax=maxval): Set the limits in degrees.

where minval and maxval are the minimum and maximum limits. Values are wrapped in to the range $$[0, 2\pi]$$ (in radians), so for example it is possible to do set_thetalim(-np.pi / 2, np.pi / 2) to have an axes symmetric around 0. A ValueError is raised if the absolute angle difference is larger than $$2\pi$$.

set_thetamax(self, thetamax)[source]

Set the maximum theta limit in degrees.

set_thetamin(self, thetamin)[source]

Set the minimum theta limit in degrees.

set_xscale(self, scale, *args, **kwargs)[source]

Set the x-axis scale.

Parameters: value{"linear", "log", "symlog", "logit", ...}The axis scale type to apply. **kwargsDifferent keyword arguments are accepted, depending on the scale. See the respective class keyword arguments:

Notes

By default, Matplotlib supports the above mentioned scales. Additionally, custom scales may be registered using matplotlib.scale.register_scale. These scales can then also be used here.

set_ylim(self, bottom=None, top=None, emit=True, auto=False, *, ymin=None, ymax=None)[source]

Set the data limits for the radial axis.

Parameters: bottomfloat, optionalThe bottom limit (default: None, which leaves the bottom limit unchanged). The bottom and top ylims may be passed as the tuple (bottom, top) as the first positional argument (or as the bottom keyword argument). topfloat, optionalThe top limit (default: None, which leaves the top limit unchanged). emitbool, default: TrueWhether to notify observers of limit change. autobool or None, default: FalseWhether to turn on autoscaling of the y-axis. True turns on, False turns off, None leaves unchanged. ymin, ymaxfloat, optionalThese arguments are deprecated and will be removed in a future version. They are equivalent to bottom and top respectively, and it is an error to pass both ymin and bottom or ymax and top. bottom, top(float, float)The new y-axis limits in data coordinates.
set_yscale(self, *args, **kwargs)[source]

Set the y-axis scale.

Parameters: value{"linear", "log", "symlog", "logit", ...}The axis scale type to apply. **kwargsDifferent keyword arguments are accepted, depending on the scale. See the respective class keyword arguments:

Notes

By default, Matplotlib supports the above mentioned scales. Additionally, custom scales may be registered using matplotlib.scale.register_scale. These scales can then also be used here.

start_pan(self, x, y, button)[source]

Called when a pan operation has started.

Parameters: x, yfloatThe mouse coordinates in display coords. buttonMouseButtonThe pressed mouse button.

Notes

This is intended to be overridden by new projection types.

class matplotlib.projections.polar.PolarTransform(axis=None, use_rmin=True, _apply_theta_transforms=True)[source]

The base polar transform. This handles projection theta and r into Cartesian coordinate space x and y, but does not perform the ultimate affine transformation into the correct position.

Parameters: shorthand_namestrA string representing the "name" of the transform. The name carries no significance other than to improve the readability of str(transform) when DEBUG=True.
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.

output_dims = 2
transform_non_affine(self, tr)[source]

Apply only the non-affine part of this transformation.

transform(values) is always equivalent to transform_affine(transform_non_affine(values)).

In non-affine transformations, this is generally equivalent to transform(values). In affine transformations, this is always a no-op.

Parameters: valuesarrayThe input values as NumPy array of length input_dims or shape (N x input_dims). arrayThe output values as NumPy array of length input_dims or shape (N x output_dims), depending on the input.
transform_path_non_affine(self, path)[source]

Apply the non-affine part of this transform to Path path, returning a new Path.

transform_path(path) is equivalent to transform_path_affine(transform_path_non_affine(values)).

class matplotlib.projections.polar.RadialAxis(*args, **kwargs)[source]

This overrides certain properties of a YAxis to provide special-casing for a radial axis.

Parameters: axesmatplotlib.axes.AxesThe Axes to which the created Axis belongs. pickradiusfloatThe acceptance radius for containment tests. See also Axis.contains.
axis_name = 'radius'

cla(self)[source]

Clear this axis.

class matplotlib.projections.polar.RadialLocator(base, axes=None)[source]

Ensures that all ticks are strictly positive. For all other tasks, it delegates to the base Locator (which may be different depending on the scale of the r-axis.

autoscale(self)[source]

[Deprecated]

Notes

Deprecated since version 3.2:

nonsingular(self, vmin, vmax)[source]

Adjust a range as needed to avoid singularities.

This method gets called during autoscaling, with (v0, v1) set to the data limits on the axes if the axes contains any data, or (-inf, +inf) if not.

• If v0 == v1 (possibly up to some floating point slop), this method returns an expanded interval around this value.
• If (v0, v1) == (-inf, +inf), this method returns appropriate default view limits.
• Otherwise, (v0, v1) is returned without modification.
pan(self, numsteps)[source]

[Deprecated]

Notes

Deprecated since version 3.3:

refresh(self)[source]

[Deprecated]

Notes

Deprecated since version 3.3:

view_limits(self, vmin, vmax)[source]

Select a scale for the range from vmin to vmax.

Subclasses should override this method to change locator behaviour.

zoom(self, direction)[source]

[Deprecated]

Notes

Deprecated since version 3.3:

class matplotlib.projections.polar.RadialTick(*args, **kwargs)[source]

This subclass of YTick provides radial ticks with some small modification to their re-positioning such that ticks are rotated based on axes limits. This results in ticks that are correctly perpendicular to the spine. Labels are also rotated to be perpendicular to the spine, when 'auto' rotation is enabled.

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

update_position(self, loc)[source]

Set the location of tick in data coords with scalar loc.

class matplotlib.projections.polar.ThetaAxis(*args, **kwargs)[source]

A theta Axis.

This overrides certain properties of an XAxis to provide special-casing for an angular axis.

Parameters: axesmatplotlib.axes.AxesThe Axes to which the created Axis belongs. pickradiusfloatThe acceptance radius for containment tests. See also Axis.contains.
axis_name = 'theta'

cla(self)[source]

Clear this axis.

class matplotlib.projections.polar.ThetaFormatter[source]

Used to format the theta tick labels. Converts the native unit of radians into degrees and adds a degree symbol.

class matplotlib.projections.polar.ThetaLocator(base)[source]

Used to locate theta ticks.

This will work the same as the base locator except in the case that the view spans the entire circle. In such cases, the previously used default locations of every 45 degrees are returned.

autoscale(self)[source]

[Deprecated]

Notes

Deprecated since version 3.2:

pan(self, numsteps)[source]

[Deprecated]

Notes

Deprecated since version 3.3:

refresh(self)[source]

[Deprecated] Refresh internal information based on current limits.

Notes

Deprecated since version 3.3.

set_axis(self, axis)[source]
view_limits(self, vmin, vmax)[source]

Select a scale for the range from vmin to vmax.

Subclasses should override this method to change locator behaviour.

zoom(self, direction)[source]

[Deprecated]

Notes

Deprecated since version 3.3:

class matplotlib.projections.polar.ThetaTick(axes, *args, **kwargs)[source]

A theta-axis tick.

This subclass of XTick provides angular ticks with some small modification to their re-positioning such that ticks are rotated based on tick location. This results in ticks that are correctly perpendicular to the arc spine.

When 'auto' rotation is enabled, labels are also rotated to be parallel to the spine. The label padding is also applied here since it's not possible to use a generic axes transform to produce tick-specific padding.

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

update_position(self, loc)[source]

Set the location of tick in data coords with scalar loc.