Add labels to the legend in the speed graph

This commit is contained in:
Paul Gauthier 2023-11-08 10:20:28 -08:00
parent 72f1c390a1
commit 02b604adc3

View file

@ -120,7 +120,7 @@ def show_stats(dirnames):
df = pd.DataFrame.from_records(rows)
df.sort_values(by=["model", "edit_format"], inplace=True)
#dump(df)
# dump(df)
plot_timing(df)
plot_outcomes(df, repeats, repeat_hi, repeat_lo, repeat_avg)
@ -131,6 +131,7 @@ def plot_timing(df):
plt.rcParams["hatch.color"] = "#444444"
from matplotlib import rc
rc("font", **{"family": "sans-serif", "sans-serif": ["Helvetica"], "size": 10})
fig, ax = plt.subplots(figsize=(6, 4))
@ -146,45 +147,15 @@ def plot_timing(df):
formats = grouped.columns
models = grouped.index
# Create a mapping for the labels and colors to ensure consistency
format_labels = {
'diff': 'Diff',
'func': 'Function',
'whole': 'Whole',
'diff-func': 'Diff-Function',
'diff-whole': 'Diff-Whole',
'func-whole': 'Function-Whole',
# Add other edit formats here if necessary
}
format_colors = {
'diff': '#b3e6a8',
'func': '#b3d1e6',
'whole': '#e6b3b3',
'diff-func': '#e6d1b3',
'diff-whole': '#b3e6d1',
'func-whole': '#d1b3e6',
# Add other edit format colors here if necessary
}
format_hatches = {
'diff': '////',
'func': '....',
'whole': '',
'diff-func': '\\\\\\\\',
'diff-whole': 'xxxx',
'func-whole': '----',
# Add other edit format hatches here if necessary
}
for i, fmt in enumerate(formats):
label = format_labels.get(fmt, fmt)
color = format_colors.get(fmt, '#b3d1e6')
hatch = format_hatches.get(fmt, '')
edge = dict(edgecolor="#ffffff", linewidth=1.5)
color = "#b3e6a8" if "diff" in fmt else "#b3d1e6"
hatch = "////" if "func" in fmt else ""
rects = ax.bar(
pos + i * width,
grouped[fmt],
width * 0.95,
label=label,
label=fmt,
color=color,
hatch=hatch,
zorder=zorder + 1,