Skip to content
Snippets Groups Projects
Commit 80fa8bc6 authored by Cornelius Oberon Pätzold's avatar Cornelius Oberon Pätzold
Browse files

Upload grouped barplot

parent e0027be1
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:b74e6051-2004-4713-b0b7-015febb66ffb tags:
``` python
import math
import pandas as pd
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.patheffects as pe
import numpy as np
```
%% Cell type:code id:c26c5978-54e3-488b-82f5-012857bb9f58 tags:
``` python
#Read csv and create a dataframe
df = pd.read_csv('stencil_2.csv')
# Calculate slowdown, and tool slowdown
#df["slowdown"] = [row["avg_t(s)"]/df.loc[(df['compile'] == "base") & (df['measurement'] == "base") & (df['tasks'] == df['tasks'].min())]["avg_t(s)"].iloc[0] for index, row in df.iterrows()]
df["tool slowdown"] = [row["avg_t(s)"]/df.loc[(df['compile'] == "base") & (df['measurement'] == "base") & (df['tasks'] == row['tasks'])]["avg_t(s)"].iloc[0] for index, row in df.iterrows()]
# Create the new feature "compile:measurement" that is the combination of the "compile" and "measurement" features.
# We use this later for the "hue" arguement in the seaborn plotting functions, which creates a color encoding based
#on the values of the "compile:measurement" feature. e.g. the data points for "base:base" and "tsan:must" will have different colors
df["compile:measurement"] = df["compile"] + ":" + df["measurement"]
display(df)
# Drop "base:must" because it is not of interest
df = df.drop(df[df["compile:measurement"] == "base:must"].index)
```
%% Output
%% Cell type:code id:8b1abc69-f247-4ab6-8df0-78b07ea405e4 tags:
``` python
custom = {"grid.linestyle": "solid", "grid.color": "white"}
sns.set_style("darkgrid", rc = custom)
#Slowdown
plt.clf()
ax = sns.barplot(x="tasks", y="tool slowdown", data=df, hue="compile:measurement", palette=["#00549f", "#8ebae5", "#fabe50"])
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12), fancybox=True, ncol=3)
#Show values
for i in ax.containers:
texts = ax.bar_label(i, fmt='%.3g', rotation=90)
for text in texts:
text.set(y=5, zorder=2000)
plt.show()
#Runtime
plt.clf()
ax = sns.barplot(x="tasks", y="avg_t(s)", data=df, hue="compile:measurement", palette=["#00549f", "#8ebae5", "#fabe50"])
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12), fancybox=True, ncol=3)
#Show values
for i in ax.containers:
texts = ax.bar_label(i, fmt='%.3g', rotation=90)
for text in texts:
text.set(y=5, zorder=2000)
plt.show()
```
%% Output
%% Cell type:code id:c5642ce4-036d-4745-80bc-e3a0d30d332b tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment