Skip to content

Commit 7f6e78b

Browse files
authored
fix: benchmark plots (#23)
1 parent b8400a7 commit 7f6e78b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/plot_benchmarks.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def read_benchmark_dir(directory: Path) -> pd.DataFrame:
3737
continue
3838
filepath = os.path.join(root, file)
3939
df = pd.read_csv(filepath, sep="\t")
40-
df["name"] = "/".join(os.path.relpath(filepath, directory).split("/")[2:])
40+
df["name"] = "/".join(
41+
str(os.path.relpath(filepath, directory)).split("/")[1:]
42+
)
4143
data.append(df)
4244
return pd.concat(data, ignore_index=True)
4345

@@ -105,12 +107,12 @@ def create_bar_chart_comparison(
105107
106108
"""
107109
if ignore_stacked_plot:
108-
fig, ax1 = plt.subplots(figsize=(8, max(6, len(df["name"].unique()) * 0.4)))
110+
fig, ax1 = plt.subplots(figsize=(8, max(6, len(df["name"].unique()) / 2)))
109111
else:
110112
fig, (ax1, ax2) = plt.subplots(
111113
1,
112114
2,
113-
figsize=(10, max(8, len(df["name"].unique()) * 0.4)),
115+
figsize=(10, max(8, len(df["name"].unique()) / 2)),
114116
gridspec_kw={"width_ratios": [3, 1]},
115117
)
116118

@@ -146,10 +148,11 @@ def create_bar_chart_comparison(
146148
ax1.set_title(f"{title} - Detailed Comparison")
147149
ax1.set_xlabel(xlabel)
148150
ax1.set_ylabel("Benchmark")
151+
ax1.margins(y=0) # Remove vertical margins
149152
if not ignore_stacked_plot:
150153
# Two single vertical bars
151154
totals = df.groupby("run")[x_column].sum()
152-
bar_width = 0.8
155+
bar_width = 1
153156
index = np.arange(len(totals))
154157

155158
for i, run in enumerate(totals.index):
@@ -173,6 +176,7 @@ def create_bar_chart_comparison(
173176
ax2.set_xlabel("Run")
174177
ax2.set_xticks(index)
175178
ax2.set_xticklabels(totals.index)
179+
ax1.margins(y=0)
176180

177181
# Remove all spines
178182
for spine in ax2.spines.values():

0 commit comments

Comments
 (0)