8000 Backport PR #13526: DOC: fix Subplot calls · matplotlib/matplotlib@9dda6f7 · GitHub
[go: up one dir, main page]

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 9dda6f7

Browse files
tacaswellMeeseeksDev[bot]
authored andcommitted
Backport PR #13526: DOC: fix Subplot calls
1 parent 45868da commit 9dda6f7

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

examples/subplots_axes_and_figures/gridspec_nested.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,16 @@ def format_axes(fig):
2424

2525
gs00 = gridspec.GridSpecFromSubplotSpec(3, 3, subplot_spec=gs0[0])
2626

27-
ax1 = plt.Subplot(f, gs00[:-1, :])
28-
f.add_subplot(ax1)
29-
ax2 = plt.Subplot(f, gs00[-1, :-1])
30-
f.add_subplot(ax2)
31-
ax3 = plt.Subplot(f, gs00[-1, -1])
32-
f.add_subplot(ax3)
33-
34-
35-
gs01 = gridspec.GridSpecFromSubplotSpec(3, 3, subplot_spec=gs0[1])
36-
37-
ax4 = plt.Subplot(f, gs01[:, :-1])
38-
f.add_subplot(ax4)
39-
ax5 = plt.Subplot(f, gs01[:-1, -1])
40-
f.add_subplot(ax5)
41-
ax6 = plt.Subplot(f, gs01[-1, -1])
42-
f.add_subplot(ax6)
27+
ax1 = f.add_subplot(gs00[:-1, :])
28+
ax2 = f.add_subplot(gs00[-1, :-1])
29+
ax3 = f.add_subplot(gs00[-1, -1])
30+
31+
# the following syntax does the same as the GridSpecFromSubplotSpec call above:
32+
gs01 = gs0[1].subgridspec(3, 3)
33+
34+
ax4 = f.add_subplot(gs01[:, :-1])
35+
ax5 = f.add_subplot(gs01[:-1, -1])
36+
ax6 = f.add_subplot(gs01[-1, -1])
4337

4438
plt.suptitle("GridSpec Inside GridSpec")
4539
format_axes(f)

tutorials/intermediate/gridspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def squiggle_xy(a, b, c, d, i=np.arange(0.0, 2*np.pi, 0.05)):
242242
inner_grid = outer_grid[i].subgridspec(3, 3, wspace=0.0, hspace=0.0)
243243
a, b = int(i/4)+1, i % 4+1
244244
for j, (c, d) in enumerate(product(range(1, 4), repeat=2)):
245-
ax = plt.Subplot(fig11, inner_grid[j])
245+
ax = fig11.add_subplot(inner_grid[j])
246246
ax.plot(*squiggle_xy(a, b, c, d))
247247
ax.set_xticks([])
248248
ax.set_yticks([])

0 commit comments

Comments
 (0)
0