aider: Plot the results using pylab, importing it at the beginning of the script and modifying the history function to display an area graph of aider_lines and total_lines over time.

# Aider chat conversation:

USER: is pylab to plot the results. x-axis is commit number. area graph showing aider_lines and total_lines over time

ASSISTANT: To plot the results using `pylab`, we need to:

1. Import `pylab` at the beginning of the script.
2. Modify the `history` function to collect the data and plot it.

Here are the *SEARCH/REPLACE* blocks:

scripts/blame.py
```python
<<<<<<< SEARCH
from pathlib import Path
=======
from pathlib import Path
import pylab as plt
>>>>>>> REPLACE
```

scripts/blame.py
```python
<<<<<<< SEARCH
    dump(results)
=======
    dump(results)

    # Plotting the results
    x = [i for i, _, _, _ in results]
    aider_lines = [aider_lines for _, aider_lines, _, _ in results]
    total_lines = [total_lines for _, _, total_lines, _ in results]

    plt.fill_between(x, aider_lines, label='Aider Lines', color='skyblue', alpha=0.5)
    plt.fill_between(x, total_lines, label='Total Lines', color='lightgreen', alpha=0.5)
    plt.xlabel('Commit Number')
    plt.ylabel('Lines of Code')
    plt.title('Aider Lines and Total Lines Over Time')
    plt.legend()
    plt.show()
>>>>>>> REPLACE
```
This commit is contained in:
Paul Gauthier 2024-05-24 09:27:07 -07:00
parent a399b99d49
commit eff8aea116

View file

@ -4,6 +4,7 @@ import tempfile
import sys import sys
import subprocess import subprocess
from pathlib import Path from pathlib import Path
import pylab as plt
from aider.dump import dump from aider.dump import dump
def get_lines_with_commit_hash(filename, aider_commits, git_dname, verbose=False): def get_lines_with_commit_hash(filename, aider_commits, git_dname, verbose=False):
@ -134,6 +135,19 @@ def history():
dump(results) dump(results)
# Plotting the results
x = [i for i, _, _, _ in results]
aider_lines = [aider_lines for _, aider_lines, _, _ in results]
total_lines = [total_lines for _, _, total_lines, _ in results]
plt.fill_between(x, aider_lines, label='Aider Lines', color='skyblue', alpha=0.5)
plt.fill_between(x, total_lines, label='Total Lines', color='lightgreen', alpha=0.5)
plt.xlabel('Commit Number')
plt.ylabel('Lines of Code')
plt.title('Aider Lines and Total Lines Over Time')
plt.legend()
plt.show()