Spaces:
Running
Running
openhands openhands commited on
Commit ·
3792b39
1
Parent(s): 894bacb
Fix Evolution Over Time chart
Browse files1. Logo positioning: Use data coordinates (xref='x', yref='y') instead of
domain coordinates for precise alignment with data points
2. Pareto frontier: Use dashed lines connecting frontier points directly,
matching the style of other charts
Co-authored-by: openhands <openhands@all-hands.dev>
- visualizations.py +18 -36
visualizations.py
CHANGED
|
@@ -187,7 +187,7 @@ def create_evolution_over_time_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 187 |
|
| 188 |
# Add Pareto frontier line (monotonically increasing best score over time)
|
| 189 |
if len(plot_df) > 1:
|
| 190 |
-
# Compute Pareto frontier:
|
| 191 |
frontier_dates = []
|
| 192 |
frontier_scores = []
|
| 193 |
max_score_so_far = float('-inf')
|
|
@@ -198,11 +198,6 @@ def create_evolution_over_time_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 198 |
|
| 199 |
if current_score > max_score_so_far:
|
| 200 |
# This point is on the Pareto frontier
|
| 201 |
-
if frontier_dates:
|
| 202 |
-
# Add a horizontal line segment from previous frontier point to this date
|
| 203 |
-
frontier_dates.append(current_date)
|
| 204 |
-
frontier_scores.append(max_score_so_far)
|
| 205 |
-
# Add the new frontier point
|
| 206 |
frontier_dates.append(current_date)
|
| 207 |
frontier_scores.append(current_score)
|
| 208 |
max_score_so_far = current_score
|
|
@@ -212,17 +207,15 @@ def create_evolution_over_time_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 212 |
x=frontier_dates,
|
| 213 |
y=frontier_scores,
|
| 214 |
mode='lines',
|
| 215 |
-
line=dict(color='#FFE165', width=2), # primary yellow,
|
| 216 |
name='Pareto Frontier',
|
| 217 |
hoverinfo='skip',
|
| 218 |
showlegend=False
|
| 219 |
))
|
| 220 |
|
| 221 |
-
# Calculate axis ranges
|
| 222 |
min_date = plot_df['release_date'].min()
|
| 223 |
max_date = plot_df['release_date'].max()
|
| 224 |
-
date_range = (max_date - min_date).total_seconds() if max_date != min_date else 1
|
| 225 |
-
|
| 226 |
min_score = plot_df[score_col].min()
|
| 227 |
max_score = plot_df[score_col].max()
|
| 228 |
y_min = min_score - 5 if min_score > 5 else 0
|
|
@@ -258,9 +251,9 @@ def create_evolution_over_time_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 258 |
)
|
| 259 |
))
|
| 260 |
|
| 261 |
-
# Add company logo images for each data point
|
| 262 |
layout_images = []
|
| 263 |
-
|
| 264 |
|
| 265 |
for _, row in plot_df.iterrows():
|
| 266 |
model_name = row.get(model_col, '')
|
|
@@ -277,47 +270,36 @@ def create_evolution_over_time_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 277 |
x_val = row['release_date']
|
| 278 |
y_val = row[score_col]
|
| 279 |
|
| 280 |
-
#
|
| 281 |
-
if date_range > 0:
|
| 282 |
-
domain_x = (x_val - min_date).total_seconds() / date_range
|
| 283 |
-
else:
|
| 284 |
-
domain_x = 0.5
|
| 285 |
-
|
| 286 |
-
domain_y = (y_val - y_min) / (y_max - y_min) if (y_max - y_min) > 0 else 0.5
|
| 287 |
-
|
| 288 |
-
# Clamp to valid range
|
| 289 |
-
domain_x = max(0.02, min(0.98, domain_x))
|
| 290 |
-
domain_y = max(0.02, min(0.98, domain_y))
|
| 291 |
-
|
| 292 |
layout_images.append(dict(
|
| 293 |
source=logo_uri,
|
| 294 |
-
xref="x
|
| 295 |
-
yref="y
|
| 296 |
-
x=
|
| 297 |
-
y=
|
| 298 |
-
sizex=
|
| 299 |
-
sizey=
|
| 300 |
xanchor="center",
|
| 301 |
yanchor="middle",
|
| 302 |
layer="above"
|
| 303 |
))
|
| 304 |
|
| 305 |
# Store label data for annotation
|
| 306 |
-
|
| 307 |
-
'x':
|
| 308 |
-
'y':
|
| 309 |
'label': model_name
|
| 310 |
})
|
| 311 |
except Exception:
|
| 312 |
pass
|
| 313 |
|
| 314 |
# Add model name labels above each point
|
| 315 |
-
for item in
|
| 316 |
fig.add_annotation(
|
| 317 |
x=item['x'],
|
| 318 |
y=item['y'],
|
| 319 |
-
xref="x
|
| 320 |
-
yref="y
|
| 321 |
text=item['label'],
|
| 322 |
showarrow=False,
|
| 323 |
yshift=20,
|
|
|
|
| 187 |
|
| 188 |
# Add Pareto frontier line (monotonically increasing best score over time)
|
| 189 |
if len(plot_df) > 1:
|
| 190 |
+
# Compute Pareto frontier: only include points that set a new best score
|
| 191 |
frontier_dates = []
|
| 192 |
frontier_scores = []
|
| 193 |
max_score_so_far = float('-inf')
|
|
|
|
| 198 |
|
| 199 |
if current_score > max_score_so_far:
|
| 200 |
# This point is on the Pareto frontier
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
frontier_dates.append(current_date)
|
| 202 |
frontier_scores.append(current_score)
|
| 203 |
max_score_so_far = current_score
|
|
|
|
| 207 |
x=frontier_dates,
|
| 208 |
y=frontier_scores,
|
| 209 |
mode='lines',
|
| 210 |
+
line=dict(color='#FFE165', width=2, dash='dash'), # primary yellow, dashed
|
| 211 |
name='Pareto Frontier',
|
| 212 |
hoverinfo='skip',
|
| 213 |
showlegend=False
|
| 214 |
))
|
| 215 |
|
| 216 |
+
# Calculate axis ranges
|
| 217 |
min_date = plot_df['release_date'].min()
|
| 218 |
max_date = plot_df['release_date'].max()
|
|
|
|
|
|
|
| 219 |
min_score = plot_df[score_col].min()
|
| 220 |
max_score = plot_df[score_col].max()
|
| 221 |
y_min = min_score - 5 if min_score > 5 else 0
|
|
|
|
| 251 |
)
|
| 252 |
))
|
| 253 |
|
| 254 |
+
# Add company logo images for each data point using data coordinates
|
| 255 |
layout_images = []
|
| 256 |
+
labels_data = []
|
| 257 |
|
| 258 |
for _, row in plot_df.iterrows():
|
| 259 |
model_name = row.get(model_col, '')
|
|
|
|
| 270 |
x_val = row['release_date']
|
| 271 |
y_val = row[score_col]
|
| 272 |
|
| 273 |
+
# Use data coordinates for precise alignment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
layout_images.append(dict(
|
| 275 |
source=logo_uri,
|
| 276 |
+
xref="x",
|
| 277 |
+
yref="y",
|
| 278 |
+
x=x_val,
|
| 279 |
+
y=y_val,
|
| 280 |
+
sizex=15 * 24 * 60 * 60 * 1000, # ~15 days in milliseconds
|
| 281 |
+
sizey=3, # score units
|
| 282 |
xanchor="center",
|
| 283 |
yanchor="middle",
|
| 284 |
layer="above"
|
| 285 |
))
|
| 286 |
|
| 287 |
# Store label data for annotation
|
| 288 |
+
labels_data.append({
|
| 289 |
+
'x': x_val,
|
| 290 |
+
'y': y_val,
|
| 291 |
'label': model_name
|
| 292 |
})
|
| 293 |
except Exception:
|
| 294 |
pass
|
| 295 |
|
| 296 |
# Add model name labels above each point
|
| 297 |
+
for item in labels_data:
|
| 298 |
fig.add_annotation(
|
| 299 |
x=item['x'],
|
| 300 |
y=item['y'],
|
| 301 |
+
xref="x",
|
| 302 |
+
yref="y",
|
| 303 |
text=item['label'],
|
| 304 |
showarrow=False,
|
| 305 |
yshift=20,
|