mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00

# Aider chat conversation: USER: reverse the order of the bars, so they go short->tall ASSISTANT: To reverse the order of the bars from short to tall, we can reverse the order of the `models` and `pass_rates` lists before plotting: benchmark/swe_bench_lite.py ```python <<<<<<< SEARCH models = [] pass_rates = [] for line in lines: if line.strip(): pass_rate, model = line.split("%") model = model.strip() model = model.replace("|", "\n") models.append(model.strip()) pass_rates.append(float(pass_rate.strip())) ======= models = [] pass_rates = [] for line in lines: if line.strip(): pass_rate, model = line.split("%") model = model.strip() model = model.replace("|", "\n") models.insert(0, model.strip()) pass_rates.insert(0, float(pass_rate.strip())) >>>>>>> REPLACE ``` This change uses `insert(0, ...)` instead of `append()` to add each model and pass rate to the beginning of their respective lists. This will effectively reverse the order, so the bars will be plotted from shortest to tallest.
71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
import matplotlib.pyplot as plt
|
|
from imgcat import imgcat
|
|
from matplotlib import rc
|
|
|
|
|
|
def plot_swe_bench_lite(data_file):
|
|
with open(data_file, "r") as file:
|
|
lines = file.readlines()
|
|
|
|
models = []
|
|
pass_rates = []
|
|
|
|
for line in lines:
|
|
if line.strip():
|
|
pass_rate, model = line.split("%")
|
|
model = model.strip()
|
|
model = model.replace("|", "\n")
|
|
models.insert(0, model.strip())
|
|
pass_rates.insert(0, float(pass_rate.strip()))
|
|
|
|
plt.rcParams["hatch.linewidth"] = 0.5
|
|
plt.rcParams["hatch.color"] = "#444444"
|
|
|
|
font_color = "#555"
|
|
rc("font", **{"family": "sans-serif", "sans-serif": ["Helvetica"], "size": 10})
|
|
plt.rcParams["text.color"] = font_color
|
|
|
|
fig, ax = plt.subplots(figsize=(10, 5))
|
|
ax.grid(axis="y", zorder=0, lw=0.2)
|
|
for spine in ax.spines.values():
|
|
spine.set_edgecolor("#DDDDDD")
|
|
spine.set_linewidth(0.5)
|
|
|
|
colors = ["#17965A" if "Aider" in model else "#b3d1e6" for model in models]
|
|
bars = []
|
|
for model, pass_rate, color in zip(models, pass_rates, colors):
|
|
alpha = 0.6 if "Aider" in model else 0.3
|
|
bar = ax.bar(model, pass_rate, color=color, alpha=alpha, zorder=3)
|
|
bars.append(bar[0])
|
|
|
|
for model, bar in zip(models, bars):
|
|
yval = bar.get_height()
|
|
y = yval + 0.75 if "Aider" in model else yval - 1.25
|
|
va = "bottom" if "Aider" in model else "top"
|
|
|
|
ax.text(
|
|
bar.get_x() + bar.get_width() / 2,
|
|
y,
|
|
f"{yval}%",
|
|
ha="center",
|
|
va=va,
|
|
fontsize=14,
|
|
)
|
|
|
|
# ax.set_xlabel("Models", fontsize=18)
|
|
ax.set_ylabel("Instances resolved (%)", fontsize=18, color=font_color)
|
|
ax.set_title("SWE Bench Lite", fontsize=20)
|
|
ax.set_ylim(0, 29.9)
|
|
plt.xticks(
|
|
fontsize=16,
|
|
color=font_color,
|
|
)
|
|
plt.tight_layout(pad=3.0)
|
|
plt.savefig("swe_bench_lite.jpg")
|
|
plt.savefig("swe_bench_lite.svg")
|
|
imgcat(fig)
|
|
ax.xaxis.label.set_color(font_color)
|
|
|
|
|
|
# Example usage
|
|
plot_swe_bench_lite("benchmark/tmp.txt")
|