mirror of
https://github.com/Lore09/Tesi-Magistrale.git
synced 2025-12-20 04:44:32 +00:00
added bar graph
This commit is contained in:
@@ -58,13 +58,11 @@ def plot_lineplot(metric, filename, color):
|
|||||||
plt.figure(figsize=(10, 6))
|
plt.figure(figsize=(10, 6))
|
||||||
sns.lineplot(x='Task', y='Time', data=subset, errorbar=('ci', 95), color=color, linewidth=2, marker='o')
|
sns.lineplot(x='Task', y='Time', data=subset, errorbar=('ci', 95), color=color, linewidth=2, marker='o')
|
||||||
|
|
||||||
# Fill missing x-axis values
|
|
||||||
min_task = subset['Task'].min()
|
min_task = subset['Task'].min()
|
||||||
max_task = subset['Task'].max()
|
max_task = subset['Task'].max()
|
||||||
all_tasks = np.arange(min_task, max_task + 1)
|
all_tasks = np.arange(min_task, max_task + 1)
|
||||||
plt.xticks(all_tasks)
|
plt.xticks(all_tasks)
|
||||||
|
|
||||||
# Label points
|
|
||||||
for i, row in subset.groupby('Task')['Time'].median().reset_index().iterrows():
|
for i, row in subset.groupby('Task')['Time'].median().reset_index().iterrows():
|
||||||
plt.text(row['Task'], row['Time'], f'{row["Time"]:.3f}', ha='center', va='bottom', fontsize=10)
|
plt.text(row['Task'], row['Time'], f'{row["Time"]:.3f}', ha='center', va='bottom', fontsize=10)
|
||||||
|
|
||||||
@@ -75,14 +73,34 @@ def plot_lineplot(metric, filename, color):
|
|||||||
plt.savefig(f'benchmark/{filename}')
|
plt.savefig(f'benchmark/{filename}')
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
|
# Function to plot bar plot with confidence intervals
|
||||||
|
def plot_barplot(metric, filename, color):
|
||||||
|
subset = df[df['Type'] == metric]
|
||||||
|
plt.figure(figsize=(10, 6))
|
||||||
|
sns.barplot(x='Task', y='Time', data=subset, color=color, errorbar=('ci', 95))
|
||||||
|
|
||||||
|
means = subset.groupby('Task')['Time'].mean()
|
||||||
|
for i, task in enumerate(means.index):
|
||||||
|
mean_value = means[task]
|
||||||
|
plt.text(i, 0, f'{mean_value:.3f}', ha='center', va='bottom', fontsize=10, alpha=0.7)
|
||||||
|
|
||||||
|
plt.ylabel('Time (seconds)')
|
||||||
|
plt.grid(True, linestyle='--', alpha=0.7)
|
||||||
|
plt.tight_layout()
|
||||||
|
plt.savefig(f'benchmark/{filename}')
|
||||||
|
plt.close()
|
||||||
|
|
||||||
# Plot each metric separately
|
# Plot each metric separately
|
||||||
plot_boxplot('Build Time', 'build_time_boxplot.png', 'skyblue')
|
plot_boxplot('Build Time', 'build_time_boxplot.png', 'skyblue')
|
||||||
plot_lineplot('Build Time', 'build_time_lineplot.png', 'skyblue')
|
plot_lineplot('Build Time', 'build_time_lineplot.png', 'skyblue')
|
||||||
|
plot_barplot('Build Time', 'build_time_barplot.png', 'skyblue')
|
||||||
|
|
||||||
plot_boxplot('Generation Time', 'gen_time_boxplot.png', 'lightgreen')
|
plot_boxplot('Generation Time', 'gen_time_boxplot.png', 'lightgreen')
|
||||||
plot_lineplot('Generation Time', 'gen_time_lineplot.png', 'lightgreen')
|
plot_lineplot('Generation Time', 'gen_time_lineplot.png', 'lightgreen')
|
||||||
|
plot_barplot('Generation Time', 'gen_time_barplot.png', 'lightgreen')
|
||||||
|
|
||||||
plot_boxplot('Deployment Time', 'deploy_time_boxplot.png', 'salmon')
|
plot_boxplot('Deployment Time', 'deploy_time_boxplot.png', 'salmon')
|
||||||
plot_lineplot('Deployment Time', 'deploy_time_lineplot.png', 'salmon')
|
plot_lineplot('Deployment Time', 'deploy_time_lineplot.png', 'salmon')
|
||||||
|
plot_barplot('Deployment Time', 'deploy_time_barplot.png', 'salmon')
|
||||||
|
|
||||||
print('Plots saved successfully in "benchmark" directory!')
|
print('Plots saved successfully in "benchmark" directory!')
|
||||||
Reference in New Issue
Block a user