@@ -41,6 +41,7 @@ def plot_pairwise_scatter(
41
41
title = None ,
42
42
figsize = (8 , 8 ),
43
43
color_palette = "tab10" ,
44
+ best_on_top = True ,
44
45
):
45
46
"""Plot a scatter that compares datasets' results achieved by two methods.
46
47
@@ -66,6 +67,9 @@ def plot_pairwise_scatter(
66
67
Size of the figure.
67
68
color_palette : str, default = "tab10"
68
69
Color palette to be used for the plot.
70
+ best_on_top : bool, default=True
71
+ If True, the estimator with better performance is placed on the y-axis (top).
72
+ If False, the ordering is reversed.
69
73
70
74
Returns
71
75
-------
@@ -129,7 +133,7 @@ def plot_pairwise_scatter(
129
133
x , y = [min_value , max_value ], [min_value , max_value ]
130
134
ax .plot (x , y , color = "black" , alpha = 0.5 , zorder = 1 )
131
135
132
- # Choose the appropriate order for the methods. Best method is shown in the y-axis.
136
+ # better estimator on top ( y-axis)
133
137
if (results_a .mean () <= results_b .mean () and not lower_better ) or (
134
138
results_a .mean () >= results_b .mean () and lower_better
135
139
):
@@ -143,6 +147,11 @@ def plot_pairwise_scatter(
143
147
second = results_b
144
148
second_method = method_b
145
149
150
+ # if best_on_top is False, swap the ordering
151
+ if not best_on_top :
152
+ first , second = second , first
153
+ first_method , second_method = second_method , first_method
154
+
146
155
differences = [
147
156
0 if i - j == 0 else (1 if i - j > 0 else - 1 ) for i , j in zip (first , second )
148
157
]
0 commit comments