From 46079135b71279005641c67df289486e7d585a08 Mon Sep 17 00:00:00 2001 From: Marcin-Ramotowski Date: Wed, 6 Aug 2025 23:30:24 +0200 Subject: [PATCH] Added more colors; added values above the bars --- data_analysis.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/data_analysis.py b/data_analysis.py index e645970..463eec6 100644 --- a/data_analysis.py +++ b/data_analysis.py @@ -29,7 +29,10 @@ groupings = [ [2, 5, 8] ] -# Folder wyjściowy (opcjonalnie) +# Kolory z palety 'tab10' +color_palette = plt.get_cmap('tab10') + +# Folder wyjściowy output_folder = "plots" os.makedirs(output_folder, exist_ok=True) @@ -37,12 +40,19 @@ os.makedirs(output_folder, exist_ok=True) for i, group in enumerate(groupings): group_labels = [labels[j] for j in group] group_means = [means[j] for j in group] - + colors = [color_palette(j % 10) for j in group] # różne kolory + plt.figure() - plt.bar(group_labels, group_means) + bars = plt.bar(group_labels, group_means, color=colors) plt.ylabel("Średni czas wdrożenia (sek)") plt.title(f"Porównanie średnich czasów wdrożenia") plt.xticks(rotation=45) + + # Dodanie wartości na słupkach + for bar in bars: + yval = bar.get_height() + plt.text(bar.get_x() + bar.get_width()/2.0, yval + 2, f'{yval:.1f}', ha='center', va='bottom', fontsize=9) + plt.tight_layout() plt.savefig(f"{output_folder}/mean_times_{i}.png") plt.close()