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.
This commit is contained in:
Paul Gauthier 2023-06-29 18:58:50 -07:00
parent e075fe9f0d
commit 0f6a90bfed

View file

@ -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")