@@ -61,6 +61,7 @@ def compute_metrics(
6161 outdir = "../media/" ,
6262 filename = None ,
6363 plot = True ,
64+ invert_yaxis = True ,
6465 plot_intensity = True ,
6566 min_max_caption : bool = False ,
6667 return_vals = True ,
@@ -91,6 +92,9 @@ def compute_metrics(
9192 Optional filename that will override the default naming scheme.
9293 plot : boolean
9394 If true, a plot will be generated, displayed, and saved.
95+ invert_yaxis : boolean
96+ If true, y axes for heatmaps will be inverted, as is commonly needed for image
97+ data.
9498 plot_intensity : boolean
9599 If false, don't plot the raw intensity images.
96100 min_max_caption : boolean
@@ -170,6 +174,8 @@ def compute_metrics(
170174 )
171175 ax [0 , j ].set_xticks ([])
172176 ax [0 , j ].set_yticks ([])
177+ if invert_yaxis :
178+ ax [0 , j ].invert_yaxis ()
173179 cbar = plt .colorbar (my_plot , shrink = 0.6 , ax = ax [0 , j ])
174180 cbar .formatter .set_powerlimits ((- 10 , 10 ))
175181 cbar .ax .tick_params (labelsize = 16 )
@@ -253,6 +259,8 @@ def compute_metrics(
253259 )
254260 ax [i , j ].set_xticks ([])
255261 ax [i , j ].set_yticks ([])
262+ if invert_yaxis :
263+ ax [i , j ].invert_yaxis ()
256264 cbar = plt .colorbar (my_plot , shrink = 0.6 , ax = ax [i , j ])
257265 cbar .formatter .set_powerlimits ((- 10 , 10 ))
258266 cbar .ax .tick_params (labelsize = 16 )
@@ -533,6 +541,7 @@ def compare_images(
533541 include_intensity_summary_plot : bool = True ,
534542 parameter_description : str = "" ,
535543 plot_heatmaps : bool = True ,
544+ invert_yaxes : bool = True ,
536545 heatmap_metric_cmap_codes : Optional [dict ] = None ,
537546 heatmap_min_max_caption : bool = False ,
538547 comparison_results : Optional [dict ] = None ,
@@ -556,6 +565,7 @@ def compare_images(
556565 "noise" and "sigma" are shorthand for longer descriptions -- otherwise, the
557566 exact string provided will be used.
558567 plot_heatmaps: whether to plot heatmaps (boolean)
568+ invert_yaxes: whether to invert heatmap yaxes
559569 heatmap_metric_cmap_codes: dictionary mapping metrics to matplotlib colormap names.
560570 heatmap_min_max_caption: whether to plot minimum and maximum metric values next to
561571 heatmaps.
@@ -590,6 +600,7 @@ def compare_images(
590600 outdir = outdir ,
591601 filename = heatmap_filename ,
592602 plot = plot_heatmaps ,
603+ invert_yaxis = invert_yaxes ,
593604 plot_intensity = True ,
594605 min_max_caption = heatmap_min_max_caption ,
595606 return_vals = True ,
0 commit comments