Spaces:
Running
Running
openhands
openhands
commited on
Commit
·
8cdce51
1
Parent(s):
4a4a7b5
Fix frontier labels to use log10 coordinates for log scale axis
Browse filesAnnotations in Plotly need log10(x) coordinates when the x-axis uses
log scale (see Plotly issue #2580). Updated the frontier label
annotations to transform x values to log10.
Co-authored-by: openhands <openhands@all-hands.dev>
- leaderboard_transformer.py +23 -29
leaderboard_transformer.py
CHANGED
|
@@ -631,13 +631,11 @@ def _plot_scatter_plotly(
|
|
| 631 |
|
| 632 |
# --- Section 7: Add Model Name Labels to Frontier Points ---
|
| 633 |
if frontier_rows:
|
| 634 |
-
|
| 635 |
-
frontier_y = []
|
| 636 |
-
frontier_labels = []
|
| 637 |
|
| 638 |
for row in frontier_rows:
|
| 639 |
-
|
| 640 |
-
|
| 641 |
|
| 642 |
# Get the model name for the label
|
| 643 |
model_name = row.get('Language Model', '')
|
|
@@ -648,29 +646,28 @@ def _plot_scatter_plotly(
|
|
| 648 |
# Truncate long names
|
| 649 |
if len(model_name) > 25:
|
| 650 |
model_name = model_name[:22] + '...'
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
mode='text',
|
| 658 |
-
name='Frontier Labels',
|
| 659 |
-
showlegend=False,
|
| 660 |
-
text=frontier_labels,
|
| 661 |
-
textposition='top center',
|
| 662 |
-
textfont=dict(
|
| 663 |
-
size=10,
|
| 664 |
-
color='#032629',
|
| 665 |
-
family='Manrope'
|
| 666 |
-
),
|
| 667 |
-
hoverinfo='skip'
|
| 668 |
-
))
|
| 669 |
|
| 670 |
-
# Add annotations for each frontier label
|
| 671 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 672 |
fig.add_annotation(
|
| 673 |
-
x=
|
| 674 |
y=y_val,
|
| 675 |
text=label,
|
| 676 |
showarrow=False,
|
|
@@ -683,9 +680,6 @@ def _plot_scatter_plotly(
|
|
| 683 |
xanchor='center',
|
| 684 |
yanchor='bottom'
|
| 685 |
)
|
| 686 |
-
|
| 687 |
-
# Remove the scatter trace we just added (we're using annotations instead)
|
| 688 |
-
fig.data = fig.data[:-1]
|
| 689 |
|
| 690 |
# --- Section 8: Configure Layout ---
|
| 691 |
# Use the same axis ranges as calculated for domain coordinates
|
|
|
|
| 631 |
|
| 632 |
# --- Section 7: Add Model Name Labels to Frontier Points ---
|
| 633 |
if frontier_rows:
|
| 634 |
+
frontier_labels_data = []
|
|
|
|
|
|
|
| 635 |
|
| 636 |
for row in frontier_rows:
|
| 637 |
+
x_val = row[x_col_to_use]
|
| 638 |
+
y_val = row[y_col_to_use]
|
| 639 |
|
| 640 |
# Get the model name for the label
|
| 641 |
model_name = row.get('Language Model', '')
|
|
|
|
| 646 |
# Truncate long names
|
| 647 |
if len(model_name) > 25:
|
| 648 |
model_name = model_name[:22] + '...'
|
| 649 |
+
|
| 650 |
+
frontier_labels_data.append({
|
| 651 |
+
'x': x_val,
|
| 652 |
+
'y': y_val,
|
| 653 |
+
'label': model_name
|
| 654 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 655 |
|
| 656 |
+
# Add annotations for each frontier label
|
| 657 |
+
# For log scale x-axis, annotations need log10(x) coordinates (Plotly issue #2580)
|
| 658 |
+
for item in frontier_labels_data:
|
| 659 |
+
x_val = item['x']
|
| 660 |
+
y_val = item['y']
|
| 661 |
+
label = item['label']
|
| 662 |
+
|
| 663 |
+
# Transform x to log10 for annotation positioning on log scale
|
| 664 |
+
if x_val > 0:
|
| 665 |
+
x_log = np.log10(x_val)
|
| 666 |
+
else:
|
| 667 |
+
x_log = x_min_log
|
| 668 |
+
|
| 669 |
fig.add_annotation(
|
| 670 |
+
x=x_log,
|
| 671 |
y=y_val,
|
| 672 |
text=label,
|
| 673 |
showarrow=False,
|
|
|
|
| 680 |
xanchor='center',
|
| 681 |
yanchor='bottom'
|
| 682 |
)
|
|
|
|
|
|
|
|
|
|
| 683 |
|
| 684 |
# --- Section 8: Configure Layout ---
|
| 685 |
# Use the same axis ranges as calculated for domain coordinates
|