@@ -169,14 +169,14 @@ def example_data():
169169 data = example_data ()
170170 spoke_labels = data .pop (0 )
171171
172- fig = plt .figure (figsize = (9 , 9 ))
172+ fig , axes = plt .subplots (figsize = (9 , 9 ), nrows = 2 , ncols = 2 ,
173+ subplot_kw = dict (projection = 'radar' ))
173174 fig .subplots_adjust (wspace = 0.25 , hspace = 0.20 , top = 0.85 , bottom = 0.05 )
174175
175176 colors = ['b' , 'r' , 'g' , 'm' , 'y' ]
176177 # Plot the four cases from the example data on separate axes
177- for n , (title , case_data ) in enumerate (data ):
178- ax = fig .add_subplot (2 , 2 , n + 1 , projection = 'radar' )
179- plt .rgrids ([0.2 , 0.4 , 0.6 , 0.8 ])
178+ for ax , (title , case_data ) in zip (axes .flatten (), data ):
179+ ax .set_rgrids ([0.2 , 0.4 , 0.6 , 0.8 ])
180180 ax .set_title (title , weight = 'bold' , size = 'medium' , position = (0.5 , 1.1 ),
181181 horizontalalignment = 'center' , verticalalignment = 'center' )
182182 for d , color in zip (case_data , colors ):
@@ -185,11 +185,12 @@ def example_data():
185185 ax .set_varlabels (spoke_labels )
186186
187187 # add legend relative to top-left plot
188- plt . subplot ( 2 , 2 , 1 )
188+ ax = axes [ 0 , 0 ]
189189 labels = ('Factor 1' , 'Factor 2' , 'Factor 3' , 'Factor 4' , 'Factor 5' )
190- legend = plt .legend (labels , loc = (0.9 , .95 ), labelspacing = 0.1 )
191- plt .setp (legend .get_texts (), fontsize = 'small' )
190+ legend = ax .legend (labels , loc = (0.9 , .95 ), labelspacing = 0.1 , fontsize = 'small' )
191+
192+ fig .text (0.5 , 0.965 , '5-Factor Solution Profiles Across Four Scenarios' ,
193+ horizontalalignment = 'center' , color = 'black' , weight = 'bold' ,
194+ size = 'large' )
192195
193- plt .figtext (0.5 , 0.965 , '5-Factor Solution Profiles Across Four Scenarios' ,
194- ha = 'center' , color = 'black' , weight = 'bold' , size = 'large' )
195196 plt .show ()
0 commit comments