mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
aider: Add labels to the bars in the plot_timing
function to display them correctly in the legend.
# Aider chat conversation: ASSISTANT: To address the issue with the empty legend for the edit format in the `plot_timing` function, we need to add labels to the bars so that the legend can display them correctly. We will modify the `benchmark/benchmark.py` file to include labels for each edit format. Here's the change that needs to be made: <source>python benchmark/benchmark.py <<<<<<< SEARCH for i, fmt in enumerate(formats): 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, color=color, hatch=hatch, zorder=zorder + 1, **edge, ) ======= # 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) rects = ax.bar( pos + i * width, grouped[fmt], width * 0.95, label=label, color=color, hatch=hatch, zorder=zorder + 1, **edge, ) >>>>>>> REPLACE </source> This change adds a mapping for labels, colors, and hatches for each edit format. It also ensures that each bar in the bar chart has a label associated with it, which will be used to generate the legend. The colors and hatches are placeholders and should be adjusted to match the desired styling.
This commit is contained in:
parent
eed4864af1
commit
867a0cc33f
1 changed files with 33 additions and 2 deletions
|
@ -146,14 +146,45 @@ 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,
|
||||
color=color,
|
||||
hatch=hatch,
|
||||
zorder=zorder + 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue