Skip to content

Commit 98b08e6

Browse files
committed
Enh(viz): Updates of plots for fig 7/8
1 parent f3dc50d commit 98b08e6

4 files changed

Lines changed: 29 additions & 7 deletions

File tree

codeclash/analysis/viz/line_chart_total_created_files_vs_round.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
from codeclash.analysis.viz.scatter_codebase_organization import (
1212
ASSETS_SUBFOLDER,
1313
DATA_CACHE,
14+
analyze_filename_redundancy_over_rounds,
1415
)
15-
from codeclash.analysis.viz.utils import FONT_BOLD, MODEL_TO_COLOR, MODEL_TO_DISPLAY_NAME
16+
from codeclash.analysis.viz.utils import FONT_BOLD, MARKERS, MODEL_TO_COLOR, MODEL_TO_DISPLAY_NAME
1617

1718

1819
def calculate_file_counts_by_extension_at_round(data: list, target_round: int = 15) -> pd.DataFrame:
@@ -107,12 +108,13 @@ def filter_outlier_tournaments_by_total_files_99p(created_files_df: pd.DataFrame
107108
return created_files_df.merge(valid_pairs, on=["player", "tournament"], how="inner")
108109

109110

110-
def plot_total_created_files_over_rounds(created_files_df: pd.DataFrame):
111+
def plot_total_created_files_over_rounds(created_files_df: pd.DataFrame, redundancy_at_r15: dict[str, float]):
111112
"""Line plot showing cumulative total created files over rounds per model.
112113
113114
- X: Round number
114115
- Y: Total number of files created (cumulative, mean across tournaments)
115116
- One line per model, colored consistently
117+
- Legend includes filename redundancy ratio at round 15
116118
"""
117119
# Aggregate by player and round (mean across all tournaments)
118120
print("------")
@@ -129,15 +131,20 @@ def plot_total_created_files_over_rounds(created_files_df: pd.DataFrame):
129131
# Figure styling to match other viz
130132
plt.figure(figsize=(6, 6))
131133

132-
# Plot one line per model with consistent color & legend label
134+
# Plot one line per model with consistent color, marker & legend label
133135
seen_labels = set()
134-
for player in sorted(agg_created["player"].unique()):
136+
for idx, player in enumerate(sorted(agg_created["player"].unique())):
135137
player_data = agg_created[agg_created["player"] == player]
136138
color = MODEL_TO_COLOR.get(player, "#333333")
137139
label = MODEL_TO_DISPLAY_NAME.get(player, player)
140+
marker = MARKERS[idx % len(MARKERS)]
141+
142+
# Get redundancy ratio for this player
143+
redundancy_pct = redundancy_at_r15.get(player, 0) * 100
144+
label_with_redundancy = f"{label} ($R={redundancy_pct:.0f}\\%$)"
138145

139146
# Avoid duplicate legend entries
140-
plot_label = label if label not in seen_labels else None
147+
plot_label = label_with_redundancy if label not in seen_labels else None
141148
if plot_label:
142149
seen_labels.add(label)
143150

@@ -146,6 +153,8 @@ def plot_total_created_files_over_rounds(created_files_df: pd.DataFrame):
146153
player_data["total_files"],
147154
color=color,
148155
linewidth=2.5,
156+
marker=marker,
157+
markersize=8,
149158
label=plot_label,
150159
alpha=0.9,
151160
)
@@ -187,8 +196,15 @@ def main():
187196
# Apply 99% per-player filtering (mirrors bar chart logic)
188197
created_files_df = filter_outlier_tournaments_by_total_files_99p(created_files_df)
189198

199+
print("\n=== Calculating Filename Redundancy at Round 15 ===")
200+
redundancy_df = analyze_filename_redundancy_over_rounds(data)
201+
redundancy_at_r15 = (
202+
redundancy_df[redundancy_df["round"] == 15].groupby("player")["redundancy_ratio"].mean().to_dict()
203+
)
204+
print(redundancy_at_r15)
205+
190206
print("\n=== Plotting Total Created Files Over Rounds ===")
191-
plot_total_created_files_over_rounds(created_files_df)
207+
plot_total_created_files_over_rounds(created_files_df, redundancy_at_r15)
192208

193209

194210
if __name__ == "__main__":

codeclash/analysis/viz/scatter_codebase_organization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def plot_filename_redundancy_over_rounds(redundancy_df: pd.DataFrame):
567567
)
568568

569569
# Figure styling to match other viz
570-
plt.figure(figsize=(6, 6))
570+
plt.figure(figsize=(3.5, 6))
571571

572572
# Plot one line per model with consistent color & legend label
573573
seen_labels = set()

codeclash/analysis/viz/throwaway_files_bar_chart.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ def plot_throwaway_files_bar_chart(throwaway_df: pd.DataFrame):
193193
total + 0.3, i, f"{total:.1f}", ha="left", va="center", fontproperties=FONT_BOLD, fontsize=14, color="black"
194194
)
195195

196+
# Set xlim to give 10% extra space for the numbers
197+
max_total = max(r + nr for r, nr in zip(root_values, non_root_values))
198+
plt.xlim(0, max_total * 1.15)
199+
196200
# Styling
197201
plt.xlabel("Throwaway Files per Tournament", fontproperties=FONT_BOLD, fontsize=18)
198202
plt.yticks(y_pos, models, fontproperties=FONT_BOLD, fontsize=14)

codeclash/analysis/viz/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@
4141
ASSETS_DIR = REPO_DIR / "assets"
4242
FONT_REG = fm.FontProperties(fname=ASSETS_DIR / "texgyrepagella-regular.otf")
4343
FONT_BOLD = fm.FontProperties(fname=ASSETS_DIR / "texgyrepagella-bold.otf")
44+
45+
MARKERS = ["o", "s", "^", "v", "D", "p", "*", "h", "H", "+", "x", "<", ">", "d"]

0 commit comments

Comments
 (0)