|
9 | 9 | from mpl_toolkits.axes_grid1 import Divider, Size
|
10 | 10 | from mpl_toolkits.axes_grid1.mpl_axes import Axes
|
11 | 11 |
|
| 12 | +############################################################################### |
12 | 13 |
|
13 |
| -def demo_fixed_size_axes(): |
14 |
| - fig = plt.figure(figsize=(6, 6)) |
15 | 14 |
|
16 |
| - # The first items are for padding and the second items are for the axes. |
17 |
| - # sizes are in inch. |
18 |
| - h = [Size.Fixed(1.0), Size.Fixed(4.5)] |
19 |
| - v = [Size.Fixed(0.7), Size.Fixed(5.)] |
| 15 | +fig = plt.figure(figsize=(6, 6)) |
20 | 16 |
|
21 |
| - divider = Divider(fig, (0.0, 0.0, 1., 1.), h, v, aspect=False) |
22 |
| - # the width and height of the rectangle is ignored. |
| 17 | +# The first items are for padding and the second items are for the axes. |
| 18 | +# sizes are in inch. |
| 19 | +h = [Size.Fixed(1.0), Size.Fixed(4.5)] |
| 20 | +v = [Size.Fixed(0.7), Size.Fixed(5.)] |
23 | 21 |
|
24 |
| - ax = Axes(fig, divider.get_position()) |
25 |
| - ax.set_axes_locator(divider.new_locator(nx=1, ny=1)) |
| 22 | +divider = Divider(fig, (0.0, 0.0, 1., 1.), h, v, aspect=False) |
| 23 | +# the width and height of the rectangle is ignored. |
26 | 24 |
|
27 |
| - fig.add_axes(ax) |
| 25 | +ax = Axes(fig, divider.get_position()) |
| 26 | +ax.set_axes_locator(divider.new_locator(nx=1, ny=1)) |
28 | 27 |
|
29 |
| - ax.plot([1, 2, 3]) |
| 28 | +fig.add_axes(ax) |
30 | 29 |
|
| 30 | +ax.plot([1, 2, 3]) |
31 | 31 |
|
32 |
| -def demo_fixed_pad_axes(): |
33 |
| - fig = plt.figure(figsize=(6, 6)) |
| 32 | +############################################################################### |
34 | 33 |
|
35 |
| - # The first & third items are for padding and the second items are for the |
36 |
| - # axes. Sizes are in inches. |
37 |
| - h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2)] |
38 |
| - v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5)] |
39 | 34 |
|
40 |
| - divider = Divider(fig, (0.0, 0.0, 1., 1.), h, v, aspect=False) |
41 |
| - # the width and height of the rectangle is ignored. |
| 35 | +fig = plt.figure(figsize=(6, 6)) |
42 | 36 |
|
43 |
| - ax = Axes(fig, divider.get_position()) |
44 |
| - ax.set_axes_locator(divider.new_locator(nx=1, ny=1)) |
| 37 | +# The first & third items are for padding and the second items are for the |
| 38 | +# axes. Sizes are in inches. |
| 39 | +h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2)] |
| 40 | +v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5)] |
45 | 41 |
|
46 |
| - fig.add_axes(ax) |
| 42 | +divider = Divider(fig, (0.0, 0.0, 1., 1.), h, v, aspect=False) |
| 43 | +# the width and height of the rectangle is ignored. |
47 | 44 |
|
48 |
| - ax.plot([1, 2, 3]) |
| 45 | +ax = Axes(fig, divider.get_position()) |
| 46 | +ax.set_axes_locator(divider.new_locator(nx=1, ny=1)) |
49 | 47 |
|
| 48 | +fig.add_axes(ax) |
50 | 49 |
|
51 |
| -if __name__ == "__main__": |
52 |
| - demo_fixed_size_axes() |
53 |
| - demo_fixed_pad_axes() |
54 |
| - |
55 |
| - plt.show() |
| 50 | +ax.plot([1, 2, 3]) |
0 commit comments