Skip to content
Snippets Groups Projects
Commit 0f6d8b37 authored by Michael Reuscher's avatar Michael Reuscher
Browse files

rework

parent 3a1082d5
No related branches found
No related tags found
1 merge request!4Python driver and data analysis part
import os
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
import os
sns.set_theme()
......@@ -10,7 +11,7 @@ class SeabornPlotter:
def __init__(self, dataframe, name, data_path):
self.dataframe = dataframe
self.name = name
self.path = os.path.join(data_path, "Plots")
self.path = os.path.join(data_path, 'Plots')
def _make_folder(self, folder_name):
folder = os.path.join(self.path, folder_name)
......@@ -43,15 +44,15 @@ class SeabornPlotter:
folder = self._make_folder('Various_Events')
x = df['size']
y = df['duration']
title = "Various Procedure: {}".format(self.name)
title = f'Various Procedure: {self.name}'
# Calculate the bins
bins_x, bins_y = self._prepare_bins(df)
# Set up the plot
f, ax = plt.subplots(figsize=(16, 9))
sns.histplot(x=x, y=y, color="blue", bins=[bins_x, bins_y])
self._add_logo("desy_logo.png", logo_size=0.1, logo_x=1.065, logo_y=0)
sns.histplot(x=x, y=y, color='blue', bins=[bins_x, bins_y])
self._add_logo('desy_logo.png', logo_size=0.1, logo_x=1.065, logo_y=0)
# Calculate the mean for x and y
mean_x_values = df.groupby('size')['size'].mean()
......@@ -64,16 +65,16 @@ class SeabornPlotter:
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel("Data size [Bytes]")
ax.set_ylabel("Time/Event [s]")
ax.set_ylabel('Time/Event [s]')
plt.title(title)
plt.grid(True)
plt.xticks(rotation=45)
plt.legend()
# Save the plot as an SVG and close
plt.savefig(os.path.join(folder, f"{title}.svg"), format='svg')
plt.savefig(os.path.join(folder, f'{title}.svg'), format='svg')
plt.close()
print(title + "Plot done!")
print(title + 'Plot done!')
def plot_scatter_long(self):
# Extract required data and set up the folder for saving the plot
......@@ -81,7 +82,7 @@ class SeabornPlotter:
folder = self._make_folder('Long_Events')
x = df['seconds_since_start']
y = df['duration']
title = "Long Procedure: {}".format(self.name)
title = f'Long Procedure: {self.name}'
# Set up the plot
f, ax = plt.subplots(figsize=(16, 9))
......@@ -136,7 +137,7 @@ class SeabornPlotter:
# Loop through each DataFrames
for df_key, df in dataframes.items():
operations = df['Group'].unique()
title = df_key.replace(".dat", "")
title = df_key.replace('.dat', '')
# Number of measures: 'min', 'max', 'mean', 'med', '10%', '90%'
num_measures = 6
......@@ -155,7 +156,7 @@ class SeabornPlotter:
global_max_speed = max(df['speed'].max() for df in dataframes.values())
# Add a logo to the plot
self._add_logo("desy_logo.png", logo_size=0.1, logo_x=1.08, logo_y=0)
self._add_logo('desy_logo.png', logo_size=0.1, logo_x=1.08, logo_y=0)
# Create subplots for each measure
for measure_idx, measure in enumerate(['min', 'max', 'mean', 'med', '10%', '90%']):
......@@ -164,7 +165,8 @@ class SeabornPlotter:
ax = axes[row_idx, col_idx]
# Create a barplot for the current measure
sns.barplot(data=df, x='Group', y='speed', hue='thread', hue_order=df['thread'].unique(), order=operations, errorbar=None, ax=ax, width=0.95, palette='cool')
sns.barplot(data=df, x='Group', y='speed', hue='thread', hue_order=df['thread'].unique(),
order=operations, errorbar=None, ax=ax, width=0.95, palette='cool')
# Set axis labels and formatting
ax.set_yscale('log')
......@@ -179,6 +181,6 @@ class SeabornPlotter:
# Save the plot as an SVG and close
plt.tight_layout()
plt.savefig(os.path.join(folder, f"{title}.svg"), format='svg')
plt.savefig(os.path.join(folder, f'{title}.svg'), format='svg')
plt.close()
print(title + " Plot done!")
print(title + ' Plot done!')
......@@ -31,9 +31,7 @@ def long(l_dataframes, statistics_path):
l_plotter.plot_scatter_long()
# --------------Main------------
def main():
# Parse Arguments
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--data_path", required=True, help="path to Data from Sim")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment