@@ -98,20 +98,12 @@ def plot_histograms(ax, prng, nb_samples=10000):
98
98
return ax
99
99
100
100
101
- def plot_figure (style_label = "" ):
101
+ def plot_figure (axs , style_label = "" ):
102
102
"""Setup and plot the demonstration figure with a given style."""
103
103
# Use a dedicated RandomState instance to draw the same "random" values
104
104
# across the different figures.
105
105
prng = np .random .RandomState (96917002 )
106
106
107
- # Tweak the figure size to be better suited for a row of numerous plots:
108
- # double the width and halve the height. NB: use relative changes because
109
- # some styles may have a figure size different from the default one.
110
- (fig_width , fig_height ) = plt .rcParams ['figure.figsize' ]
111
- fig_size = [fig_width * 2 , fig_height / 2 ]
112
-
113
- fig , axs = plt .subplots (ncols = 6 , nrows = 1 , num = style_label ,
114
- figsize = fig_size , squeeze = True )
115
107
axs [0 ].set_ylabel (style_label )
116
108
117
109
plot_scatter (axs [0 ], prng )
@@ -121,10 +113,6 @@ def plot_figure(style_label=""):
121
113
plot_colored_sinusoidal_lines (axs [4 ])
122
114
plot_histograms (axs [5 ], prng )
123
115
124
- fig .tight_layout ()
125
-
126
- return fig
127
-
128
116
129
117
if __name__ == "__main__" :
130
118
@@ -133,11 +121,14 @@ def plot_figure(style_label=""):
133
121
# first and second position.
134
122
style_list = ['default' , 'classic' ] + sorted (
135
123
style for style in plt .style .available if style != 'classic' )
124
+ nstyles = len (style_list )
136
125
126
+ fig , axs = plt .subplots (ncols = 6 , nrows = nstyles , figsize = (12 , 3 * nstyles ))
137
127
# Plot a demonstration figure for every available style sheet.
138
- for style_label in style_list :
128
+ for axs_row , style_label in zip ( axs , style_list ) :
139
129
with plt .rc_context ({"figure.max_open_warning" : len (style_list )}):
140
130
with plt .style .context (style_label ):
141
- fig = plot_figure (style_label = style_label )
131
+ plot_figure (axs_row , style_label = style_label )
142
132
133
+ fig .tight_layout ()
143
134
plt .show ()
0 commit comments