@@ -31,7 +31,7 @@ def example_plot(ax):
31
31
32
32
fig , ax = plt .subplots ()
33
33
example_plot (ax )
34
- plt .tight_layout ()
34
+ fig .tight_layout ()
35
35
36
36
###############################################################################
37
37
@@ -40,61 +40,53 @@ def example_plot(ax):
40
40
example_plot (ax2 )
41
41
example_plot (ax3 )
42
42
example_plot (ax4 )
43
- plt .tight_layout ()
43
+ fig .tight_layout ()
44
44
45
45
###############################################################################
46
46
47
47
fig , (ax1 , ax2 ) = plt .subplots (nrows = 2 , ncols = 1 )
48
48
example_plot (ax1 )
49
49
example_plot (ax2 )
50
- plt .tight_layout ()
50
+ fig .tight_layout ()
51
51
52
52
###############################################################################
53
53
54
54
fig , (ax1 , ax2 ) = plt .subplots (nrows = 1 , ncols = 2 )
55
55
example_plot (ax1 )
56
56
example_plot (ax2 )
57
- plt .tight_layout ()
57
+ fig .tight_layout ()
58
58
59
59
###############################################################################
60
60
61
61
fig , axs = plt .subplots (nrows = 3 , ncols = 3 )
62
62
for ax in axs .flat :
63
63
example_plot (ax )
64
- plt .tight_layout ()
64
+ fig .tight_layout ()
65
65
66
66
###############################################################################
67
67
68
- fig = plt .figure ()
69
-
68
+ plt .figure ()
70
69
ax1 = plt .subplot (221 )
71
70
ax2 = plt .subplot (223 )
72
71
ax3 = plt .subplot (122 )
73
-
74
72
example_plot (ax1 )
75
73
example_plot (ax2 )
76
74
example_plot (ax3 )
77
-
78
75
plt .tight_layout ()
79
76
80
77
###############################################################################
81
78
82
- fig = plt .figure ()
83
-
79
+ plt .figure ()
84
80
ax1 = plt .subplot2grid ((3 , 3 ), (0 , 0 ))
85
81
ax2 = plt .subplot2grid ((3 , 3 ), (0 , 1 ), colspan = 2 )
86
82
ax3 = plt .subplot2grid ((3 , 3 ), (1 , 0 ), colspan = 2 , rowspan = 2 )
87
83
ax4 = plt .subplot2grid ((3 , 3 ), (1 , 2 ), rowspan = 2 )
88
-
89
84
example_plot (ax1 )
90
85
example_plot (ax2 )
91
86
example_plot (ax3 )
92
87
example_plot (ax4 )
93
-
94
88
plt .tight_layout ()
95
89
96
- plt .show ()
97
-
98
90
###############################################################################
99
91
100
92
fig = plt .figure ()
@@ -103,20 +95,16 @@ def example_plot(ax):
103
95
ax1 = fig .add_subplot (gs1 [0 ])
104
96
ax2 = fig .add_subplot (gs1 [1 ])
105
97
ax3 = fig .add_subplot (gs1 [2 ])
106
-
107
98
example_plot (ax1 )
108
99
example_plot (ax2 )
109
100
example_plot (ax3 )
110
-
111
101
gs1 .tight_layout (fig , rect = [None , None , 0.45 , None ])
112
102
113
103
gs2 = fig .add_gridspec (2 , 1 )
114
104
ax4 = fig .add_subplot (gs2 [0 ])
115
105
ax5 = fig .add_subplot (gs2 [1 ])
116
-
117
106
example_plot (ax4 )
118
107
example_plot (ax5 )
119
-
120
108
with warnings .catch_warnings ():
121
109
# gs2.tight_layout cannot handle the subplots from the first gridspec
122
110
# (gs1), so it will raise a warning. We are going to match the gridspecs
0 commit comments