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

Skip to content

Commit 5a92cb0

Browse files
committed
MNT: simplify generating GridSpec
1 parent d5fdb0d commit 5a92cb0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/matplotlib/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,7 @@ def _do_layout(gs, layout, unique_ids, nested):
16771677

16781678
layout = np.asarray(layout, dtype=object)
16791679
rows, cols = layout.shape
1680-
gs = GridSpec(rows, cols, figure=self, **gridspec_kw)
1680+
gs = self.add_gridspec(rows, cols, **gridspec_kw)
16811681
return _do_layout(gs, layout, *_process_layout(layout))
16821682

16831683
def delaxes(self, ax):

lib/matplotlib/tests/test_build_grid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_basic(fig_test, fig_ref):
1010
for k, ax in grid_axes.items():
1111
ax.set_title(k)
1212

13-
gs = gridspec.GridSpec(2, 3, figure=fig_ref)
13+
gs = fig_ref.add_gridspec(2, 3)
1414
axA = fig_ref.add_subplot(gs[:1, :2])
1515
axA.set_title("A")
1616

@@ -35,7 +35,7 @@ def test_recursive(fig_test, fig_ref):
3535
for k, ax in grid_axes.items():
3636
ax.set_title(k)
3737

38-
gs = gridspec.GridSpec(2, 1, figure=fig_ref)
38+
gs = fig_ref.add_gridspec(2, 1)
3939
axF = fig_ref.add_subplot(gs[0, 0])
4040
axF.set_title("F")
4141

0 commit comments

Comments
 (0)