Skip to content

Commit 3966075

Browse files
committed
modifying benchmarks
1 parent 77bd09b commit 3966075

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

examples/plot_benchmark_custom.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,29 @@ def benchmark_radius_clustering():
184184
fig.suptitle("Benchmark of Radius Clustering Solvers", fontsize=16)
185185

186186
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():
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+
197210
for 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

212224
axs["iris"].set_ylabel("Number of clusters")
213225
axs["glass"].set_ylabel("Number of clusters")
214226

215227
axs['time'].set_title("Execution Time (log scale)")
216228
axs['time'].set_xlabel("Datasets")
217229
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)
218232
axs['time'].legend(title="Algorithms")
219233
plt.tight_layout()
220234
plt.show()

0 commit comments

Comments
 (0)