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 4034b85

Browse filesBrowse files
jklymakMeeseeksDev[bot]
authored andcommitted
Backport PR #10792: Fixed not being able to set vertical/horizontal alignments in polar graphs
1 parent beef8ba commit 4034b85
Copy full SHA for 4034b85

File tree

Expand file treeCollapse file tree

3 files changed

+34
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+34
-2
lines changed

‎lib/matplotlib/projections/polar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/polar.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,8 @@ def update_position(self, loc):
635635
text_angle = user_angle
636636
if self.label1On:
637637
if full:
638-
ha = 'left'
639-
va = 'bottom'
638+
ha = self.label1.get_ha()
639+
va = self.label1.get_va()
640640
else:
641641
ha, va = self._determine_anchor(mode, angle, direction > 0)
642642
self.label1.set_ha(ha)
Loading

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,38 @@ def test_polar_coord_annotations():
456456
ax.set_ylim(-20, 20)
457457

458458

459+
@image_comparison(baseline_images=['polar_alignment'], extensions=['png'])
460+
def test_polar_alignment():
461+
'''
462+
Test that changing the vertical/horizontal alignment of a polar graph
463+
works as expected '''
464+
ranges = [(0, 5), (0, 5)]
465+
466+
angles = np.arange(0, 360, 90)
467+
468+
levels = 5
469+
470+
fig = plt.figure()
471+
472+
figureSize = [0.1, 0.1, 0.8, 0.8]
473+
474+
horizontal = fig.add_axes(figureSize, polar=True, label='horizontal')
475+
vertical = fig.add_axes(figureSize, polar=True, label='vertical')
476+
477+
axes = [horizontal, vertical]
478+
479+
horizontal.set_thetagrids(angles)
480+
481+
vertical.patch.set_visible(False)
482+
483+
for i in range(2):
484+
grid = np.linspace(*ranges[i], num=levels)
485+
gridValues = [0, 0.2, 0.4, 0.6, 0.8, 1]
486+
axes[i].set_rgrids(gridValues, angle=angles[i],
487+
horizontalalignment='left',
488+
verticalalignment='top')
489+
490+
459491
@image_comparison(baseline_images=['fill_units'], extensions=['png'],
460492
savefig_kwarg={'dpi': 60})
461493
def test_fill_units():

0 commit comments

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