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 357979e

Browse filesBrowse files
committed
Fix colorbar stealing from a single axes and with panchor=False.
This was accidentally broken in 16d639b: `panchor` and `loc_settings["panchor"]` can be different, so it is incorrect to replace one by the other.
1 parent f670fe7 commit 357979e
Copy full SHA for 357979e

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+9
-1
lines changed

‎lib/matplotlib/colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ def make_axes_gridspec(parent, *, location=None, orientation=None,
16171617
aspect = 1 / aspect
16181618

16191619
parent.set_subplotspec(ss_main)
1620-
parent.set_anchor(panchor)
1620+
parent.set_anchor(loc_settings["panchor"])
16211621

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

‎lib/matplotlib/tests/test_colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colorbar.py
+8Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.