@@ -184,16 +184,29 @@ def benchmark_radius_clustering():
184
184
fig .suptitle ("Benchmark of Radius Clustering Solvers" , fontsize = 16 )
185
185
186
186
axs ['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():
188
188
# 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
+ # )
195
195
# Plot number of clusters
196
196
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
+
197
210
for i , (name , (dataset , _ )) in enumerate (DATASETS .items ()):
198
211
axs [name ].bar (
199
212
results .keys (),
@@ -207,14 +220,15 @@ def benchmark_radius_clustering():
207
220
linestyle = '--' ,
208
221
)
209
222
axs [name ].set_title (name )
210
- axs [name ].set_xlabel ("Algorithms" )
211
223
212
224
axs ["iris" ].set_ylabel ("Number of clusters" )
213
225
axs ["glass" ].set_ylabel ("Number of clusters" )
214
226
215
227
axs ['time' ].set_title ("Execution Time (log scale)" )
216
228
axs ['time' ].set_xlabel ("Datasets" )
217
229
axs ['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 )
218
232
axs ['time' ].legend (title = "Algorithms" )
219
233
plt .tight_layout ()
220
234
plt .show ()
0 commit comments