|
7 | 7 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
8 | 8 | from mpl_toolkits.axes_grid1.axes_divider import make_axes_area_auto_adjustable |
9 | 9 |
|
10 | | -import matplotlib.pyplot as plt |
11 | 10 |
|
12 | | -def ex1(): |
13 | | - plt.figure(1) |
14 | | - ax = plt.axes([0, 0, 1, 1]) |
15 | | - #ax = plt.subplot(111) |
| 11 | +plt.figure() |
| 12 | +ax = plt.axes([0, 0, 1, 1]) |
| 13 | +#ax = plt.subplot(111) |
16 | 14 |
|
17 | | - ax.set_yticks([0.5]) |
18 | | - ax.set_yticklabels(["very long label"]) |
| 15 | +ax.set_yticks([0.5]) |
| 16 | +ax.set_yticklabels(["very long label"]) |
19 | 17 |
|
20 | | - make_axes_area_auto_adjustable(ax) |
21 | | - |
22 | | -ex1() |
| 18 | +make_axes_area_auto_adjustable(ax) |
23 | 19 |
|
24 | 20 | ############################################################################### |
25 | 21 |
|
26 | 22 |
|
27 | | -def ex2(): |
28 | | - |
29 | | - plt.figure(2) |
30 | | - ax1 = plt.axes([0, 0, 1, 0.5]) |
31 | | - ax2 = plt.axes([0, 0.5, 1, 0.5]) |
| 23 | +plt.figure() |
| 24 | +ax1 = plt.axes([0, 0, 1, 0.5]) |
| 25 | +ax2 = plt.axes([0, 0.5, 1, 0.5]) |
32 | 26 |
|
33 | | - ax1.set_yticks([0.5]) |
34 | | - ax1.set_yticklabels(["very long label"]) |
35 | | - ax1.set_ylabel("Y label") |
| 27 | +ax1.set_yticks([0.5]) |
| 28 | +ax1.set_yticklabels(["very long label"]) |
| 29 | +ax1.set_ylabel("Y label") |
36 | 30 |
|
37 | | - ax2.set_title("Title") |
| 31 | +ax2.set_title("Title") |
38 | 32 |
|
39 | | - make_axes_area_auto_adjustable(ax1, pad=0.1, use_axes=[ax1, ax2]) |
40 | | - make_axes_area_auto_adjustable(ax2, pad=0.1, use_axes=[ax1, ax2]) |
41 | | - |
42 | | -ex2() |
| 33 | +make_axes_area_auto_adjustable(ax1, pad=0.1, use_axes=[ax1, ax2]) |
| 34 | +make_axes_area_auto_adjustable(ax2, pad=0.1, use_axes=[ax1, ax2]) |
43 | 35 |
|
44 | 36 | ############################################################################### |
45 | 37 |
|
46 | 38 |
|
47 | | -def ex3(): |
48 | | - |
49 | | - fig = plt.figure(3) |
50 | | - ax1 = plt.axes([0, 0, 1, 1]) |
51 | | - divider = make_axes_locatable(ax1) |
| 39 | +fig = plt.figure() |
| 40 | +ax1 = plt.axes([0, 0, 1, 1]) |
| 41 | +divider = make_axes_locatable(ax1) |
52 | 42 |
|
53 | | - ax2 = divider.new_horizontal("100%", pad=0.3, sharey=ax1) |
54 | | - ax2.tick_params(labelleft=False) |
55 | | - fig.add_axes(ax2) |
| 43 | +ax2 = divider.new_horizontal("100%", pad=0.3, sharey=ax1) |
| 44 | +ax2.tick_params(labelleft=False) |
| 45 | +fig.add_axes(ax2) |
56 | 46 |
|
57 | | - divider.add_auto_adjustable_area(use_axes=[ax1], pad=0.1, |
58 | | - adjust_dirs=["left"]) |
59 | | - divider.add_auto_adjustable_area(use_axes=[ax2], pad=0.1, |
60 | | - adjust_dirs=["right"]) |
61 | | - divider.add_auto_adjustable_area(use_axes=[ax1, ax2], pad=0.1, |
62 | | - adjust_dirs=["top", "bottom"]) |
| 47 | +divider.add_auto_adjustable_area(use_axes=[ax1], pad=0.1, |
| 48 | + adjust_dirs=["left"]) |
| 49 | +divider.add_auto_adjustable_area(use_axes=[ax2], pad=0.1, |
| 50 | + adjust_dirs=["right"]) |
| 51 | +divider.add_auto_adjustable_area(use_axes=[ax1, ax2], pad=0.1, |
| 52 | + adjust_dirs=["top", "bottom"]) |
63 | 53 |
|
64 | | - ax1.set_yticks([0.5]) |
65 | | - ax1.set_yticklabels(["very long label"]) |
| 54 | +ax1.set_yticks([0.5]) |
| 55 | +ax1.set_yticklabels(["very long label"]) |
66 | 56 |
|
67 | | - ax2.set_title("Title") |
68 | | - ax2.set_xlabel("X - Label") |
| 57 | +ax2.set_title("Title") |
| 58 | +ax2.set_xlabel("X - Label") |
69 | 59 |
|
70 | | -ex3() |
71 | 60 | plt.show() |
0 commit comments