@@ -121,19 +121,26 @@ def plot_results_against_bandlimit(
121
121
measurements : tuple [str ] = ("times" , "flops" , "memory" , "error" ),
122
122
axis_size : float = 3.0 ,
123
123
fig_dpi : int = 100 ,
124
+ functions_along_columns : bool = False ,
124
125
) -> tuple [plt .Figure , plt .Axes ]:
125
126
benchmark_results_path = Path (benchmark_results_path )
126
127
with benchmark_results_path .open ("r" ) as f :
127
128
benchmark_results = json .load (f )
128
129
n_functions = len (functions )
129
130
n_measurements = len (measurements )
131
+ n_rows , n_cols = (
132
+ (n_measurements , n_functions )
133
+ if functions_along_columns
134
+ else (n_functions , n_measurements )
135
+ )
130
136
fig , axes = plt .subplots (
131
- n_functions ,
132
- n_measurements ,
133
- figsize = (axis_size * n_measurements , axis_size * n_functions ),
137
+ n_rows ,
138
+ n_cols ,
139
+ figsize = (axis_size * n_cols , axis_size * n_rows ),
134
140
dpi = fig_dpi ,
135
141
squeeze = False ,
136
142
)
143
+ axes = axes .T if functions_along_columns else axes
137
144
for axes_row , function in zip (axes , functions ):
138
145
results = benchmark_results ["results" ][function ]
139
146
l_values = np .array ([r ["parameters" ]["L" ] for r in results ])
@@ -183,6 +190,11 @@ def _parse_cli_arguments() -> argparse.Namespace:
183
190
parser .add_argument (
184
191
"-title" , type = str , help = "Title for figure. No title added if omitted."
185
192
)
193
+ parser .add_argument (
194
+ "--functions-along-columns" ,
195
+ action = "store_true" ,
196
+ help = "Whether to orient axes with functions along columns instead of rows." ,
197
+ )
186
198
return parser .parse_args ()
187
199
188
200
@@ -202,6 +214,7 @@ def _parse_cli_arguments() -> argparse.Namespace:
202
214
measurements = measurements ,
203
215
axis_size = args .axis_size ,
204
216
fig_dpi = args .dpi ,
217
+ functions_along_columns = args .functions_along_columns ,
205
218
)
206
219
if args .title is not None :
207
220
fig .suptitle (args .title )
0 commit comments