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 ad70feb

Browse filesBrowse files
Charles Ruanbr-Zhang
authored andcommitted
Change to how update_position is decided to allow full circle polar graphs to have the correct alignments set.
1 parent 0d0eb39 commit ad70feb
Copy full SHA for ad70feb

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
@@ -631,8 +631,8 @@ def update_position(self, loc):
631631
text_angle = user_angle
632632
if self.label1On:
633633
if full:
634-
ha = 'left'
635-
va = 'bottom'
634+
ha = self.label1.get_ha()
635+
va = self.label1.get_va()
636636
else:
637637
ha, va = self._determine_anchor(mode, angle, direction > 0)
638638
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
@@ -454,6 +454,38 @@ def test_polar_coord_annotations():
454454
ax.set_ylim(-20, 20)
455455

456456

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