@@ -178,11 +178,16 @@ def plot_metric(metric: str, out_path: Path):
178178 # Determine modes to plot, optionally limiting to top-N by mean of metric
179179 all_modes = sorted ({m for c in cats for m in cat_by_mode .get (c , {}).keys ()})
180180 if len (all_modes ) > 0 :
181+
181182 def _mean (values ):
182183 vals = [v for v in values if v is not None ]
183184 return sum (vals ) / len (vals ) if vals else float ("nan" )
184185
185- if args .max_modes is not None and args .max_modes > 0 and len (all_modes ) > args .max_modes :
186+ if (
187+ args .max_modes is not None
188+ and args .max_modes > 0
189+ and len (all_modes ) > args .max_modes
190+ ):
186191 mode_means = []
187192 for mode in all_modes :
188193 vals = [cat_by_mode .get (c , {}).get (mode , {}).get (metric ) for c in cats ]
@@ -279,7 +284,9 @@ def _mean(values):
279284 ax .set_xlim (left_xlim , right_xlim )
280285 ylabel = metric .replace ("_" , " " )
281286 ax .set_ylabel (ylabel , fontsize = int (18 * args .font_scale ))
282- ax .set_title (f"Per-category { ylabel } per-mode values" , fontsize = int (22 * args .font_scale ))
287+ ax .set_title (
288+ f"Per-category { ylabel } per-mode values" , fontsize = int (22 * args .font_scale )
289+ )
283290 ax .tick_params (axis = "both" , which = "major" , labelsize = int (14 * args .font_scale ))
284291
285292 # Build a figure-level legend below the axes and reserve space to prevent overlap
@@ -290,7 +297,7 @@ def _mean(values):
290297 legend_rows = 2
291298 legend_ncol = max (1 , (num_series + legend_rows - 1 ) // legend_rows )
292299 num_rows = legend_rows
293- scale = ( args .font_scale / 1.6 )
300+ scale = args .font_scale / 1.6
294301 # Reserve generous space for long rotated tick labels and multi-row legend
295302 bottom_reserved = (0.28 * scale ) + (0.12 * num_rows * scale )
296303 bottom_reserved = max (0.24 , min (0.60 , bottom_reserved ))
0 commit comments