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

Skip to content

Commit 819c483

Browse files
committed
DOC: fix Subplot calls
1 parent 17d16f9 commit 819c483

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

examples/subplots_axes_and_figures/gridspec_nested.py

Lines changed: 6 additions & 12 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)
27+
ax1 = f.add_subplot(gs00[:-1, :])
28+
ax2 = f.add_subplot(gs00[-1, :-1])
29+
ax3 = f.add_subplot(gs00[-1, -1])
3330

3431

3532
gs01 = gridspec.GridSpecFromSubplotSpec(3, 3, subplot_spec=gs0[1])
3633

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)
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)