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 708c0f3

Browse filesBrowse files
committed
FIX: do not reset ylabel ha when changing position
closes #18427
1 parent 5b835ee commit 708c0f3
Copy full SHA for 708c0f3

File tree

2 files changed

+12
-2
lines changed
Filter options

2 files changed

+12
-2
lines changed

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,8 +2339,7 @@ def set_label_position(self, position):
23392339
position : {'left', 'right'}
23402340
"""
23412341
self.label.set_rotation_mode('anchor')
2342-
self.label.set_horizontalalignment('center')
2343-
self.label.set_verticalalignment(_api.check_getitem({
2342+
self.label.set_verticalalignment(cbook._check_getitem({
23442343
'left': 'bottom', 'right': 'top',
23452344
}, position=position))
23462345
self.label_position = position

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
image_comparison, check_figures_equal, remove_ticks_and_titles)
2424
import matplotlib.colors as mcolors
2525
import matplotlib.dates as mdates
26+
from matplotlib.figure import Figure
2627
import matplotlib.font_manager as mfont_manager
2728
import matplotlib.markers as mmarkers
2829
import matplotlib.patches as mpatches
@@ -6758,3 +6759,13 @@ def test_2dcolor_plot(fig_test, fig_ref):
67586759
axs[2].step([1, 2], [1, 2], c=color.reshape((1, -1)))
67596760
axs[3].hist(np.arange(10), color=color.reshape((1, -1)))
67606761
axs[4].bar(np.arange(10), np.arange(10), color=color.reshape((1, -1)))
6762+
6763+
6764+
@pytest.mark.parametrize('ha', ['left', 'center', 'right'])
6765+
def test_ylabel_ha_with_position(ha):
6766+
6767+
fig = Figure()
6768+
ax = fig.subplots()
6769+
ax.set_ylabel("test", y=1, ha=ha)
6770+
ax.yaxis.set_label_position("right")
6771+
assert ax.yaxis.get_label().get_ha() == ha

0 commit comments

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