Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bb8b04b

Browse filesBrowse files
committed
Fix transforms of polar ticks and grids.
1 parent d1e5ccb commit bb8b04b
Copy full SHA for bb8b04b

File tree

Expand file treeCollapse file tree

1 file changed

+22
-18
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-18
lines changed

‎lib/matplotlib/projections/polar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/polar.py
+22-18Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -417,20 +417,20 @@ def _set_lim_and_transforms(self):
417417
(self.transProjectionAffine + self.transAxes)
418418

419419
# This is the transform for theta-axis ticks. It is
420-
# equivalent to transData, except it always puts r == 1.0 at
421-
# the edge of the axis circle.
420+
# equivalent to transData, except it always puts r == 0.0 and r == 1.0
421+
# at the edge of the axis circles.
422422
self._xaxis_transform = (
423-
self.transPureProjection +
424-
self.PolarAffine(IdentityTransform(), Bbox.unit()) +
423+
blended_transform_factory(IdentityTransform(),
424+
BboxTransformTo(self.viewLim)) +
425+
self.transProjection +
426+
self.PolarAffine(IdentityTransform(), self._offsetViewLim) +
425427
self.transAxes)
426428
# The theta labels are moved from radius == 0.0 to radius == 1.1
427-
self._theta_label1_position = Affine2D().translate(0.0, 1.1)
428429
self._xaxis_text1_transform = (
429-
self._theta_label1_position +
430+
Affine2D().translate(0.0, -0.1) +
430431
self._xaxis_transform)
431-
self._theta_label2_position = Affine2D().translate(0.0, 1.0 / 1.1)
432432
self._xaxis_text2_transform = (
433-
self._theta_label2_position +
433+
Affine2D().scale(1.0, 1.1) +
434434
self._xaxis_transform)
435435

436436
# This is the transform for r-axis ticks. It scales the theta
@@ -439,7 +439,9 @@ def _set_lim_and_transforms(self):
439439
self._yaxis_transform = (
440440
blended_transform_factory(BboxTransformTo(self.viewLim),
441441
IdentityTransform()) +
442-
self.transData)
442+
self.transProjection +
443+
self.PolarAffine(IdentityTransform(), self._offsetViewLim) +
444+
self.transAxes)
443445
# The r-axis labels are put at an angle and padded in the r-direction
444446
self._r_label_position = ScaledTranslation(
445447
self._default_rlabel_position, 0.0, Affine2D())
@@ -529,12 +531,17 @@ def _gen_axes_patch(self):
529531
return Wedge((0.5, 0.5), 0.5, 0.0, 360.0)
530532

531533
def _gen_axes_spines(self):
532-
return {'polar': mspines.Spine.arc_spine(self, 'top',
533-
(0.5, 0.5), 0.5, 0.0, 360.0),
534-
'start': mspines.Spine.linear_spine(self, 'left'),
535-
'end': mspines.Spine.linear_spine(self, 'right'),
536-
'inner': mspines.Spine.arc_spine(self, 'bottom',
537-
(0.5, 0.5), 0.0, 0.0, 360.0)}
534+
spines = {'polar': mspines.Spine.arc_spine(self, 'top',
535+
(0.5, 0.5), 0.5,
536+
0.0, 360.0),
537+
'start': mspines.Spine.linear_spine(self, 'left'),
538+
'end': mspines.Spine.linear_spine(self, 'right'),
539+
'inner': mspines.Spine.arc_spine(self, 'bottom',
540+
(0.5, 0.5), 0.0,
541+
0.0, 360.0)}
542+
spines['start'].set_transform(self._yaxis_transform)
543+
spines['end'].set_transform(self._yaxis_transform)
544+
return spines
538545

539546
def set_thetamax(self, thetamax):
540547
self.viewLim.x1 = np.deg2rad(thetamax)
@@ -707,9 +714,6 @@ def set_thetagrids(self, angles, labels=None, frac=None, fmt=None,
707714
self.set_xticklabels(labels)
708715
elif fmt is not None:
709716
self.xaxis.set_major_formatter(FormatStrFormatter(fmt))
710-
if frac is not None:
711-
self._theta_label1_position.clear().translate(0.0, frac)
712-
self._theta_label2_position.clear().translate(0.0, 1.0 / frac)
713717
for t in self.xaxis.get_ticklabels():
714718
t.update(kwargs)
715719
return self.xaxis.get_ticklines(), self.xaxis.get_ticklabels()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.