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

Skip to content

Commit ad318d9

Browse files
authored
Merge pull request #22781 from meeseeksmachine/auto-backport-of-pr-22776-on-v3.5.x
Backport PR #22776 on branch v3.5.x (Fix colorbar stealing from a single axes and with panchor=False.)
2 parents 18f864d + c7171b3 commit ad318d9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/matplotlib/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ def make_axes_gridspec(parent, *, location=None, orientation=None,
15991599
aspect = 1 / aspect
16001600

16011601
parent.set_subplotspec(ss_main)
1602-
parent.set_anchor(panchor)
1602+
parent.set_anchor(loc_settings["panchor"])
16031603

16041604
fig = parent.get_figure()
16051605
cax = fig.add_subplot(ss_cb, label="<colorbar>")

lib/matplotlib/tests/test_colorbar.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ def test_colorbar_positioning(use_gridspec):
210210
anchor=(0.8, 0.5), shrink=0.6, use_gridspec=use_gridspec)
211211

212212

213+
def test_colorbar_single_ax_panchor_false():
214+
# Just smoketesting that this doesn't crash. Note that this differs from
215+
# the tests above with panchor=False because there use_gridspec is actually
216+
# ineffective: passing *ax* as lists always disable use_gridspec.
217+
plt.imshow([[0, 1]])
218+
plt.colorbar(panchor=False)
219+
220+
213221
@image_comparison(['contour_colorbar.png'], remove_text=True)
214222
def test_contour_colorbar():
215223
fig, ax = plt.subplots(figsize=(4, 2))

0 commit comments

Comments
 (0)