From 02b604adc3d9e1e8e073d9a8e89439609f027afa Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 8 Nov 2023 10:20:28 -0800 Subject: [PATCH] Add labels to the legend in the speed graph --- benchmark/benchmark.py | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index 58e33af62..02530804b 100755 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -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,