@@ -31,7 +31,7 @@ def example_plot(ax):
3131
3232fig , ax = plt .subplots ()
3333example_plot (ax )
34- plt .tight_layout ()
34+ fig .tight_layout ()
3535
3636###############################################################################
3737
@@ -40,61 +40,53 @@ def example_plot(ax):
4040example_plot (ax2 )
4141example_plot (ax3 )
4242example_plot (ax4 )
43- plt .tight_layout ()
43+ fig .tight_layout ()
4444
4545###############################################################################
4646
4747fig , (ax1 , ax2 ) = plt .subplots (nrows = 2 , ncols = 1 )
4848example_plot (ax1 )
4949example_plot (ax2 )
50- plt .tight_layout ()
50+ fig .tight_layout ()
5151
5252###############################################################################
5353
5454fig , (ax1 , ax2 ) = plt .subplots (nrows = 1 , ncols = 2 )
5555example_plot (ax1 )
5656example_plot (ax2 )
57- plt .tight_layout ()
57+ fig .tight_layout ()
5858
5959###############################################################################
6060
6161fig , axs = plt .subplots (nrows = 3 , ncols = 3 )
6262for ax in axs .flat :
6363 example_plot (ax )
64- plt .tight_layout ()
64+ fig .tight_layout ()
6565
6666###############################################################################
6767
68- fig = plt .figure ()
69-
68+ plt .figure ()
7069ax1 = plt .subplot (221 )
7170ax2 = plt .subplot (223 )
7271ax3 = plt .subplot (122 )
73-
7472example_plot (ax1 )
7573example_plot (ax2 )
7674example_plot (ax3 )
77-
7875plt .tight_layout ()
7976
8077###############################################################################
8178
82- fig = plt .figure ()
83-
79+ plt .figure ()
8480ax1 = plt .subplot2grid ((3 , 3 ), (0 , 0 ))
8581ax2 = plt .subplot2grid ((3 , 3 ), (0 , 1 ), colspan = 2 )
8682ax3 = plt .subplot2grid ((3 , 3 ), (1 , 0 ), colspan = 2 , rowspan = 2 )
8783ax4 = plt .subplot2grid ((3 , 3 ), (1 , 2 ), rowspan = 2 )
88-
8984example_plot (ax1 )
9085example_plot (ax2 )
9186example_plot (ax3 )
9287example_plot (ax4 )
93-
9488plt .tight_layout ()
9589
96- plt .show ()
97-
9890###############################################################################
9991
10092fig = plt .figure ()
@@ -103,20 +95,16 @@ def example_plot(ax):
10395ax1 = fig .add_subplot (gs1 [0 ])
10496ax2 = fig .add_subplot (gs1 [1 ])
10597ax3 = fig .add_subplot (gs1 [2 ])
106-
10798example_plot (ax1 )
10899example_plot (ax2 )
109100example_plot (ax3 )
110-
111101gs1 .tight_layout (fig , rect = [None , None , 0.45 , None ])
112102
113103gs2 = fig .add_gridspec (2 , 1 )
114104ax4 = fig .add_subplot (gs2 [0 ])
115105ax5 = fig .add_subplot (gs2 [1 ])
116-
117106example_plot (ax4 )
118107example_plot (ax5 )
119-
120108with warnings .catch_warnings ():
121109 # gs2.tight_layout cannot handle the subplots from the first gridspec
122110 # (gs1), so it will raise a warning. We are going to match the gridspecs
0 commit comments