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 c5c7cce

Browse filesBrowse files
QuLogicmeeseeksmachine
authored andcommitted
Backport PR #23569: Fix hidden xlabel bug in colorbar
1 parent 30c6d28 commit c5c7cce
Copy full SHA for c5c7cce

File tree

Expand file treeCollapse file tree

3 files changed

+11
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+11
-1
lines changed

‎lib/matplotlib/colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ def __init__(self, ax, mappable=None, *, cmap=None,
353353
for spine in self.ax.spines.values():
354354
spine.set_visible(False)
355355
self.outline = self.ax.spines['outline'] = _ColorbarSpine(self.ax)
356-
self._short_axis().set_visible(False)
357356
# Only kept for backcompat; remove after deprecation of .patch elapses.
358357
self._patch = mpatches.Polygon(
359358
np.empty((0, 2)),
Loading

‎lib/matplotlib/tests/test_colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colorbar.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,17 @@ def test_colorbar_label():
721721
assert cbar3.ax.get_xlabel() == 'horizontal cbar'
722722

723723

724+
@image_comparison(['colorbar_keeping_xlabel.png'], style='mpl20')
725+
def test_keeping_xlabel():
726+
# github issue #23398 - xlabels being ignored in colorbar axis
727+
arr = np.arange(25).reshape((5, 5))
728+
fig, ax = plt.subplots()
729+
im = ax.imshow(arr)
730+
cbar = plt.colorbar(im)
731+
cbar.ax.set_xlabel('Visible Xlabel')
732+
cbar.set_label('YLabel')
733+
734+
724735
@pytest.mark.parametrize("clim", [(-20000, 20000), (-32768, 0)])
725736
def test_colorbar_int(clim):
726737
# Check that we cast to float early enough to not

0 commit comments

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