Skip to content

Commit 20bbec3

Browse files
committed
polar: Clarify some of the documenting comments on transforms
1 parent 4f3daae commit 20bbec3

File tree

1 file changed

+38
-43
lines changed

1 file changed

+38
-43
lines changed

lib/matplotlib/projections/polar.py

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,11 @@ def _init_axis(self):
879879
self.spines['polar'].register_axis(self.yaxis)
880880

881881
def _set_lim_and_transforms(self):
882-
# A view limit where the minimum radius can be locked if the user
883-
# specifies an alternate origin.
882+
# self.viewLim is set by the superclass and contains (θ, r) as its (x, y)
883+
# components.
884+
885+
# This is a view limit (still in (θ, r) space) where the minimum radius can be
886+
# locked if the user specifies an alternate origin.
884887
self._originViewLim = mtransforms.LockableBbox(self.viewLim)
885888

886889
# Handle angular offset and direction.
@@ -889,30 +892,26 @@ def _set_lim_and_transforms(self):
889892
self._theta_offset = mtransforms.Affine2D() \
890893
.translate(self._default_theta_offset, 0.0)
891894
self.transShift = self._direction + self._theta_offset
892-
# A view limit shifted to the correct location after accounting for
893-
# orientation and offset.
894-
self._realViewLim = mtransforms.TransformedBbox(self.viewLim,
895-
self.transShift)
896-
897-
# Transforms the x and y axis separately by a scale factor
898-
# It is assumed that this part will have non-linear components
899-
self.transScale = mtransforms.TransformWrapper(
900-
mtransforms.IdentityTransform())
901-
902-
# Scale view limit into a bbox around the selected wedge. This may be
903-
# smaller than the usual unit axes rectangle if not plotting the full
904-
# circle.
905-
self.axesLim = _WedgeBbox((0.5, 0.5),
906-
self._realViewLim, self._originViewLim)
907-
908-
# Scale the wedge to fill the axes.
895+
# This is a view limit in (θ, r) shifted to the correct location after
896+
# accounting for θ orientation and offset.
897+
self._realViewLim = mtransforms.TransformedBbox(self.viewLim, self.transShift)
898+
899+
# Transforms the θ and r axis separately by a scale factor. It is assumed that
900+
# this part will have the non-linear components.
901+
self.transScale = mtransforms.TransformWrapper(mtransforms.IdentityTransform())
902+
903+
# Scale view limit into a bbox around the selected wedge. This may be smaller
904+
# than the usual unit axes rectangle if not plotting the full circle.
905+
self.axesLim = _WedgeBbox((0.5, 0.5), self._realViewLim, self._originViewLim)
906+
907+
# Scale the wedge to fill the Axes unit space.
909908
self.transWedge = mtransforms.BboxTransformFrom(self.axesLim)
910909

911-
# Scale the axes to fill the figure.
910+
# Scale the Axes unit space to fill the Axes actual position.
912911
self.transAxes = mtransforms.BboxTransformTo(self.bbox)
913912

914-
# A (possibly non-linear) projection on the (already scaled)
915-
# data. This one is aware of rmin
913+
# A (possibly non-linear) projection on the (already scaled) data. This one is
914+
# aware of rmin.
916915
self.transProjection = self.PolarTransform(
917916
self,
918917
apply_theta_transforms=False,
@@ -921,52 +920,48 @@ def _set_lim_and_transforms(self):
921920
# Add dependency on rorigin.
922921
self.transProjection.set_children(self._originViewLim)
923922

924-
# An affine transformation on the data, generally to limit the
925-
# range of the axes
923+
# An affine transformation on the data, generally to limit the range of the axes
926924
self.transProjectionAffine = self.PolarAffine(self.transScale,
927925
self._originViewLim)
928926

929-
# The complete data transformation stack -- from data all the
930-
# way to display coordinates
931-
#
932-
# 1. Remove any radial axis scaling (e.g. log scaling)
933-
# 2. Shift data in the theta direction
934-
# 3. Project the data from polar to cartesian values
935-
# (with the origin in the same place)
936-
# 4. Scale and translate the cartesian values to Axes coordinates
937-
# (here the origin is moved to the lower left of the Axes)
938-
# 5. Move and scale to fill the Axes
939-
# 6. Convert from Axes coordinates to Figure coordinates
927+
# The complete data transformation stack -- from data all the way to display
928+
# coordinates.
940929
self.transData = (
930+
# 1. Remove any radial axis scaling (e.g. log scaling).
941931
self.transScale +
932+
# 2. Shift data in the θ direction.
942933
self.transShift +
934+
# 3. Project the data from polar to cartesian values (with the origin in the
935+
# same place).
943936
self.transProjection +
944937
(
938+
# 4. Scale and translate the cartesian values to Axes coordinates (here
939+
# the origin is moved to the lower left of the Axes).
945940
self.transProjectionAffine +
941+
# 5. Move and scale to fill the Axes.
946942
self.transWedge +
943+
# 6. Convert from Axes coordinates to Figure coordinates.
947944
self.transAxes
948945
)
949946
)
950947

951-
# This is the transform for theta-axis ticks. It is
952-
# equivalent to transData, except it always puts r == 0.0 and r == 1.0
953-
# at the edge of the axis circles.
948+
# This is the transform for θ-axis ticks. It is equivalent to transData, except
949+
# it always puts r == 0.0 and r == 1.0 at the edge of the axis circles.
954950
self._xaxis_transform = (
955951
mtransforms.blended_transform_factory(
956952
mtransforms.IdentityTransform(),
957953
mtransforms.BboxTransformTo(self.viewLim)) +
958954
self.transData)
959-
# The theta labels are flipped along the radius, so that text 1 is on
960-
# the outside by default. This should work the same as before.
955+
# The θ labels are flipped along the radius, so that text 1 is on the outside by
956+
# default. This should work the same as before.
961957
flipr_transform = mtransforms.Affine2D() \
962958
.translate(0.0, -0.5) \
963959
.scale(1.0, -1.0) \
964960
.translate(0.0, 0.5)
965961
self._xaxis_text_transform = flipr_transform + self._xaxis_transform
966962

967-
# This is the transform for r-axis ticks. It scales the theta
968-
# axis so the gridlines from 0.0 to 1.0, now go from thetamin to
969-
# thetamax.
963+
# This is the transform for r-axis ticks. It scales the θ-axis so the gridlines
964+
# from 0.0 to 1.0, now go from thetamin to thetamax.
970965
self._yaxis_transform = (
971966
mtransforms.blended_transform_factory(
972967
mtransforms.BboxTransformTo(self.viewLim),

0 commit comments

Comments
 (0)