Skip to content

Commit 785a9a5

Browse files
committed
Revert joining of figures in Axes Divider example.
1 parent e6f4ee2 commit 785a9a5

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

examples/axes_grid1/simple_axes_divider1.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,51 @@ def label_axes(ax, text):
1818
left=False, labelleft=False)
1919

2020

21-
fig = plt.figure(figsize=(12, 6))
22-
sfs = fig.subfigures(1, 2)
21+
##############################################################################
22+
# Fixed axes sizes; fixed paddings.
2323

24+
fig = plt.figure(figsize=(6, 6))
25+
fig.suptitle("Fixed axes sizes, fixed paddings")
2426

25-
sfs[0].suptitle("Fixed axes sizes, fixed paddings")
2627
# Sizes are in inches.
2728
horiz = [Size.Fixed(1.), Size.Fixed(.5), Size.Fixed(1.5), Size.Fixed(.5)]
2829
vert = [Size.Fixed(1.5), Size.Fixed(.5), Size.Fixed(1.)]
2930

3031
rect = (0.1, 0.1, 0.8, 0.8)
3132
# Divide the axes rectangle into a grid with sizes specified by horiz * vert.
32-
div = Divider(sfs[0], rect, horiz, vert, aspect=False)
33+
div = Divider(fig, rect, horiz, vert, aspect=False)
3334

3435
# The rect parameter will actually be ignored and overridden by axes_locator.
35-
ax1 = sfs[0].add_axes(rect, axes_locator=div.new_locator(nx=0, ny=0))
36+
ax1 = fig.add_axes(rect, axes_locator=div.new_locator(nx=0, ny=0))
3637
label_axes(ax1, "nx=0, ny=0")
37-
ax2 = sfs[0].add_axes(rect, axes_locator=div.new_locator(nx=0, ny=2))
38+
ax2 = fig.add_axes(rect, axes_locator=div.new_locator(nx=0, ny=2))
3839
label_axes(ax2, "nx=0, ny=2")
39-
ax3 = sfs[0].add_axes(rect, axes_locator=div.new_locator(nx=2, ny=2))
40+
ax3 = fig.add_axes(rect, axes_locator=div.new_locator(nx=2, ny=2))
4041
label_axes(ax3, "nx=2, ny=2")
41-
ax4 = sfs[0].add_axes(rect, axes_locator=div.new_locator(nx=2, nx1=4, ny=0))
42+
ax4 = fig.add_axes(rect, axes_locator=div.new_locator(nx=2, nx1=4, ny=0))
4243
label_axes(ax4, "nx=2, nx1=4, ny=0")
4344

45+
##############################################################################
46+
# Axes sizes that scale with the figure size; fixed paddings.
47+
48+
fig = plt.figure(figsize=(6, 6))
49+
fig.suptitle("Scalable axes sizes, fixed paddings")
4450

45-
sfs[1].suptitle("Scalable axes sizes, fixed paddings")
46-
# Fixed sizes are in inches, scaled sizes are relative.
4751
horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.), Size.Scaled(.5)]
4852
vert = [Size.Scaled(1.), Size.Fixed(.5), Size.Scaled(1.5)]
4953

5054
rect = (0.1, 0.1, 0.8, 0.8)
5155
# Divide the axes rectangle into a grid with sizes specified by horiz * vert.
52-
div = Divider(sfs[1], rect, horiz, vert, aspect=False)
56+
div = Divider(fig, rect, horiz, vert, aspect=False)
5357

5458
# The rect parameter will actually be ignored and overridden by axes_locator.
55-
ax1 = sfs[1].add_axes(rect, axes_locator=div.new_locator(nx=0, ny=0))
59+
ax1 = fig.add_axes(rect, axes_locator=div.new_locator(nx=0, ny=0))
5660
label_axes(ax1, "nx=0, ny=0")
57-
ax2 = sfs[1].add_axes(rect, axes_locator=div.new_locator(nx=0, ny=2))
61+
ax2 = fig.add_axes(rect, axes_locator=div.new_locator(nx=0, ny=2))
5862
label_axes(ax2, "nx=0, ny=2")
59-
ax3 = sfs[1].add_axes(rect, axes_locator=div.new_locator(nx=2, ny=2))
63+
ax3 = fig.add_axes(rect, axes_locator=div.new_locator(nx=2, ny=2))
6064
label_axes(ax3, "nx=2, ny=2")
61-
ax4 = sfs[1].add_axes(rect, axes_locator=div.new_locator(nx=2, nx1=4, ny=0))
65+
ax4 = fig.add_axes(rect, axes_locator=div.new_locator(nx=2, nx1=4, ny=0))
6266
label_axes(ax4, "nx=2, nx1=4, ny=0")
6367

64-
6568
plt.show()

0 commit comments

Comments
 (0)