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 cdd0c57

Browse filesBrowse files
authored
Merge pull request #13528 from meeseeksmachine/auto-backport-of-pr-13526-on-v3.1.x
Backport PR #13526 on branch v3.1.x (DOC: fix Subplot calls)
2 parents 45868da + 9dda6f7 commit cdd0c57
Copy full SHA for cdd0c57

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+11
-17
lines changed

‎examples/subplots_axes_and_figures/gridspec_nested.py

Copy file name to clipboardExpand all lines: examples/subplots_axes_and_figures/gridspec_nested.py
+10-16Lines 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

Copy file name to clipboardExpand all lines: tutorials/intermediate/gridspec.py
+1-1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.