From 0f6a90bfed5ff381623f490f121e340a4b2b3783 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 29 Jun 2023 18:58:50 -0700 Subject: [PATCH] aider: Switched the plt stuff to use an explicit fig. # Context: USER: switch the plt stuff to use an explicit fig ASSISTANT: To switch the matplotlib plotting to use an explicit figure, we need to modify the `show_stats` function in the `benchmark/benchmark.py` file. Here are the changes: ```python benchmark/benchmark.py <<<<<<< ORIGINAL df_grouped.unstack().plot(kind="barh", figsize=(10, 6)) plt.xlabel("Pass Rate 1") plt.ylabel("Model") plt.title("Pass Rate 1 for each Model/Edit Format") plt.legend(title="Edit Format") plt.show() ======= fig, ax = plt.subplots(figsize=(10, 6)) df_grouped.unstack().plot(kind="barh", ax=ax) ax.set_xlabel("Pass Rate 1") ax.set_ylabel("Model") ax.set_title("Pass Rate 1 for each Model/Edit Format") ax.legend(title="Edit Format") plt.show() >>>>>>> UPDATED ``` This change creates a new figure and axes before plotting, and then uses the axes for setting labels, title, and legend. This is a more explicit way of handling figures and axes in matplotlib. --- benchmark/benchmark.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index fcfc4512c..3fd8ebb60 100755 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -52,12 +52,13 @@ def show_stats(dirnames): df_grouped = df.groupby(["model", "edit_format"])["pass_rate_1"].mean() dump(df_grouped) dump(df_grouped.unstack()) - df_grouped.unstack().plot(kind="barh", figsize=(10, 6)) + fig, ax = plt.subplots(figsize=(10, 6)) + df_grouped.unstack().plot(kind="barh", ax=ax) - plt.xlabel("Pass Rate 1") - plt.ylabel("Model") - plt.title("Pass Rate 1 for each Model/Edit Format") - plt.legend(title="Edit Format") + ax.set_xlabel("Pass Rate 1") + ax.set_ylabel("Model") + ax.set_title("Pass Rate 1 for each Model/Edit Format") + ax.legend(title="Edit Format") plt.show() # df.to_csv("tmp.benchmarks.csv")