Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb77150

Browse files
committed
Fix hidden xlabel bug in colorbar
1 parent 1368cfe commit bb77150

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
@@ -713,6 +713,17 @@ def test_colorbar_label():
713713
assert cbar3.ax.get_xlabel() == 'horizontal cbar'
714714

715715

716+
@image_comparison(['colorbar_keeping_xlabel.png'], style='mpl20')
717+
def test_keeping_xlabel():
718+
# github issue #23398 - xlabels being ignored in colorbar axis
719+
arr = np.arange(25).reshape((5, 5))
720+
fig, ax = plt.subplots()
721+
im = ax.imshow(arr)
722+
cbar = plt.colorbar(im)
723+
cbar.ax.set_xlabel('Visible Xlabel')
724+
cbar.set_label('YLabel')
725+
726+
716727
@pytest.mark.parametrize("clim", [(-20000, 20000), (-32768, 0)])
717728
def test_colorbar_int(clim):
718729
# Check that we cast to float early enough to not

0 commit comments

Comments
 (0)