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 03b8e19

Browse filesBrowse files
authored
Merge pull request #10594 from jklymak/fix-cl-colorbar
FIX: colorbar check for constrained layout
2 parents ef15140 + e5f073c commit 03b8e19
Copy full SHA for 03b8e19

File tree

Expand file treeCollapse file tree

2 files changed

+17
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-2
lines changed

‎lib/matplotlib/colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.py
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,12 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
11321132
parents = np.atleast_1d(parents).ravel()
11331133

11341134
# check if using constrained_layout:
1135-
gs = parents[0].get_subplotspec().get_gridspec()
1136-
using_constrained_layout = (gs._layoutbox is not None)
1135+
try:
1136+
gs = parents[0].get_subplotspec().get_gridspec()
1137+
using_constrained_layout = (gs._layoutbox is not None)
1138+
except AttributeError:
1139+
using_constrained_layout = False
1140+
11371141
# defaults are not appropriate for constrained_layout:
11381142
pad0 = loc_settings['pad']
11391143
if using_constrained_layout:

‎lib/matplotlib/tests/test_constrainedlayout.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_constrainedlayout.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,14 @@ def test_constrained_layout19():
377377
ax.set_title('')
378378
fig.canvas.draw()
379379
assert all(ax.get_position().extents == ax2.get_position().extents)
380+
381+
382+
def test_constrained_layout20():
383+
'Smoke test cl does not mess up added axes'
384+
gx = np.linspace(-5, 5, 4)
385+
img = np.hypot(gx, gx[:, None])
386+
387+
fig = plt.figure()
388+
ax = fig.add_axes([0, 0, 1, 1])
389+
mesh = ax.pcolormesh(gx, gx, img)
390+
fig.colorbar(mesh)

0 commit comments

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