Skip to content

Commit e5cfa0f

Browse files
committed
Add docs for polar transform
1 parent f063fd2 commit e5cfa0f

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

lib/matplotlib/projections/polar.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ class PolarTransform(mtransforms.Transform):
2020
The base polar transform.
2121
2222
This transform maps polar coordinates ``(theta, r)`` into Cartesian
23-
coordinates ``(x, y) = (r * cos(theta), r * sin(theta))`` (but does not
23+
coordinates ``(x, y) = (r * cos(theta), r * sin(theta))`` (but does not fully transform into Axes coordinates or
2424
handle positioning in screen space).
2525
26+
This transformation is designed to be applied to data after any scaling
27+
along the radial axis (e.g. log-scaling) has been applied to the input
28+
data.
29+
2630
Path segments at a fixed radius are automatically transformed to circular
2731
arcs as long as ``path._interpolation_steps > 1``.
2832
"""
@@ -882,7 +886,9 @@ def _set_lim_and_transforms(self):
882886
# data. This one is aware of rmin
883887
self.transProjection = self.PolarTransform(
884888
self,
885-
_apply_theta_transforms=False, scale_transform=self.transScale)
889+
_apply_theta_transforms=False,
890+
scale_transform=self.transScale
891+
)
886892
# Add dependency on rorigin.
887893
self.transProjection.set_children(self._originViewLim)
888894

@@ -893,9 +899,25 @@ def _set_lim_and_transforms(self):
893899

894900
# The complete data transformation stack -- from data all the
895901
# way to display coordinates
902+
#
903+
# 1. Remove any radial axis scaling (e.g. log scaling)
904+
# 2. Shift data in the theta direction
905+
# 3. Project the data from polar to cartesian values
906+
# (with the origin in the same place)
907+
# 4. Scale and translate the cartesian values to Axes coordinates
908+
# (here the origin is moved to the lower left of the Axes)
909+
# 5. Move and scale to fill the Axes
910+
# 6. Convert from Axes coordinates to Figure coordinates
896911
self.transData = (
897-
self.transScale + self.transShift + self.transProjection +
898-
(self.transProjectionAffine + self.transWedge + self.transAxes))
912+
self.transScale +
913+
self.transShift +
914+
self.transProjection +
915+
(
916+
self.transProjectionAffine +
917+
self.transWedge +
918+
self.transAxes
919+
)
920+
)
899921

900922
# This is the transform for theta-axis ticks. It is
901923
# equivalent to transData, except it always puts r == 0.0 and r == 1.0

0 commit comments

Comments
 (0)