@@ -184,16 +184,29 @@ def benchmark_radius_clustering():
184184fig .suptitle ("Benchmark of Radius Clustering Solvers" , fontsize = 16 )
185185
186186axs ['time' ].set_yscale ('log' ) # Use logarithmic scale for better visibility
187- for algo , algo_results in results .items ():
187+ # for algo, algo_results in results.items():
188188 # Plot execution time
189- axs ['time' ].plot (
190- DATASETS .keys (),
191- algo_results ["time" ],
192- marker = 'o' ,
193- label = algo ,
194- )
189+ # axs['time'].plot(
190+ # DATASETS.keys(),
191+ # algo_results["time"],
192+ # marker='o',
193+ # label=algo,
194+ # )
195195 # Plot number of clusters
196196
197+ algorithms = list (results .keys ())
198+ dataset_names = list (DATASETS .keys ())
199+ n_algos = len (algorithms )
200+ x_indices = np .arange (len (dataset_names )) # the label locations
201+ bar_width = 0.8 / n_algos # the width of the bars, with some padding
202+
203+ for i , algo in enumerate (algorithms ):
204+ times = results [algo ]["time" ]
205+ # Calculate position for each bar in the group to center them
206+ position = x_indices - (n_algos * bar_width / 2 ) + (i * bar_width ) + bar_width / 2
207+ axs ['time' ].bar (position , times , bar_width , label = algo )
208+ # --- End of change ---
209+
197210for i , (name , (dataset , _ )) in enumerate (DATASETS .items ()):
198211 axs [name ].bar (
199212 results .keys (),
@@ -207,14 +220,15 @@ def benchmark_radius_clustering():
207220 linestyle = '--' ,
208221 )
209222 axs [name ].set_title (name )
210- axs [name ].set_xlabel ("Algorithms" )
211223
212224axs ["iris" ].set_ylabel ("Number of clusters" )
213225axs ["glass" ].set_ylabel ("Number of clusters" )
214226
215227axs ['time' ].set_title ("Execution Time (log scale)" )
216228axs ['time' ].set_xlabel ("Datasets" )
217229axs ['time' ].set_ylabel ("Time (seconds)" )
230+ axs ['time' ].set_xticks (x_indices ) # Set tick positions to be at the center of the groups
231+ axs ['time' ].set_xticklabels (dataset_names )
218232axs ['time' ].legend (title = "Algorithms" )
219233plt .tight_layout ()
220234plt .show ()
0 commit comments