8000 Merge pull request #15513 from ardieorden/docs/separate_plots_axes_grid1 · matplotlib/matplotlib@0f88d8c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f88d8c

Browse files
authored
Merge pull request #15513 from ardieorden/docs/separate_plots_axes_grid1
Separate plots using #### in make_room_for_ylabel_using_axesgrid.py
2 parents 34fa840 + d78314f commit 0f88d8c

File tree

1 file changed

+36
-41
lines changed

1 file changed

+36
-41
lines changed

examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,59 @@
44
===================================
55
66
"""
7+
8+
import matplotlib.pyplot as plt
9+
710
from mpl_toolkits.axes_grid1 import make_axes_locatable
811
from mpl_toolkits.axes_grid1.axes_divider import make_axes_area_auto_adjustable
912

1013

11-
if __name__ == "__main__":
12-
13-
import matplotlib.pyplot as plt
14+
plt.figure()
15+
ax = plt.axes([0, 0, 1, 1])
1416

15-
def ex1():
16-
plt.figure(1)
17-
ax = plt.axes([0, 0, 1, 1])
18-
#ax = plt.subplot(111)
17+
ax.set_yticks([0.5])
18+
ax.set_yticklabels(["very long label"])
1919

20-
ax.set_yticks([0.5])
21-
ax.set_yticklabels(["very long label"])
20+
make_axes_area_auto_adjustable(ax)
2221

23-
make_axes_area_auto_adjustable(ax)
22+
###############################################################################
2423

25-
def ex2():
2624

27-
plt.figure(2)
28-
ax1 = plt.axes([0, 0, 1, 0.5])
29-
ax2 = plt.axes([0, 0.5, 1, 0.5])
25+
plt.figure()
26+
ax1 = plt.axes([0, 0, 1, 0.5])
27+
ax2 = plt.axes([0, 0.5, 1, 0.5])
3028

31-
ax1.set_yticks([0.5])
32-
ax1.set_yticklabels(["very long label"])
33-
ax1.set_ylabel("Y label")
29+
ax1.set_yticks([0.5])
30+
ax1.set_yticklabels(["very long label"])
31+
ax1.set_ylabel("Y label")
3432

35-
ax2.set_title("Title")
33+
ax2.set_title("Title")
3634

37-
make_axes_area_auto_adjustable(ax1, pad=0.1, use_axes=[ax1, ax2])
38-
make_axes_area_auto_adjustable(ax2, pad=0.1, use_axes=[ax1, ax2])
35+
make_axes_area_auto_adjustable(ax1, pad=0.1, use_axes=[ax1, ax2])
36+
make_axes_area_auto_adjustable(ax2, pad=0.1, use_axes=[ax1, ax2])
3937

40-
def ex3():
38+
###############################################################################
4139

42-
fig = plt.figure(3)
43-
ax1 = plt.axes([0, 0, 1, 1])
44-
divider = make_axes_locatable(ax1)
4540

46-
ax2 = divider.new_horizontal("100%", pad=0.3, sharey=ax1)
47-
ax2.tick_params(labelleft=False)
48-
fig.add_axes(ax2)
41+
fig = plt.figure()
42+
ax1 = plt.axes([0, 0, 1, 1])
43+
divider = make_axes_locatable(ax1)
4944

50-
divider.add_auto_adjustable_area(use_axes=[ax1], pad=0.1,
51-
adjust_dirs=["left"])
52-
divider.add_auto_adjustable_area(use_axes=[ax2], pad=0.1,
53-
adjust_dirs=["right"])
54-
divider.add_auto_adjustable_area(use_axes=[ax1, ax2], pad=0.1,
55-
adjust_dirs=["top", "bottom"])
45+
ax2 = divider.new_horizontal("100%", pad=0.3, sharey=ax1)
46+
ax2.tick_params(labelleft=False)
47+
fig.add_axes(ax2)
5648

57-
ax1.set_yticks([0.5])
58-
ax1.set_yticklabels(["very long label"])
49+
divider.add_auto_adjustable_area(use_axes=[ax1], pad=0.1,
50+
adjust_dirs=["left"])
51+
divider.add_auto_adjustable_area(use_axes=[ax2], pad=0.1,
52+
adjust_dirs=["right"])
53+
divider.add_auto_adjustable_area(use_axes=[ax1, ax2], pad=0.1,
54+
adjust_dirs=["top", "bottom"])
5955

60-
ax2.set_title("Title")
61-
ax2.set_xlabel("X - Label")
56+
ax1.set_yticks([0.5])
57+
ax1.set_yticklabels(["very long label"])
6258

63-
ex1()
64-
ex2()
65-
ex3()
59+
ax2.set_title("Title")
60+
ax2.set_xlabel("X - Label")
6661

67-
plt.show()
62+
plt.show()

0 commit comments

Comments
 (0)
0