Skip to content

Commit bdf83bb

Browse files
authored
Merge pull request #23569 from kianelbo/cb-xlabel
Fix hidden xlabel bug in colorbar
2 parents cf4d812 + bb77150 commit bdf83bb

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lib/matplotlib/colorbar.py

Lines 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)),

lib/matplotlib/tests/test_colorbar.py

Lines 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)