kshitijthakkar commited on
Commit
2d9152d
·
1 Parent(s): c2ee0af

fix: Add explicit log scale range for cost-performance chart

Browse files

Set explicit X-axis range in log scale to ensure proper model distribution
across the cost spectrum. This forces Plotly to render the full range from
minimum to maximum cost values.

Changes:
- Calculate min/max cost from display values
- Set explicit xaxis range using log10 calculations
- Range padded by 0.5x min and 2x max for better visibility

Files changed (1) hide show
  1. components/analytics_charts.py +10 -1
components/analytics_charts.py CHANGED
@@ -432,6 +432,10 @@ def create_cost_efficiency_scatter(df: pd.DataFrame) -> go.Figure:
432
  font=dict(size=20)
433
  )
434
 
 
 
 
 
435
  fig.update_layout(
436
  title={
437
  'text': '💰 Cost-Performance Efficiency',
@@ -442,6 +446,12 @@ def create_cost_efficiency_scatter(df: pd.DataFrame) -> go.Figure:
442
  xaxis_title='Total Cost (USD)',
443
  yaxis_title='Success Rate (%)',
444
  xaxis_type='log', # Log scale for cost
 
 
 
 
 
 
445
  height=600,
446
  plot_bgcolor='white',
447
  paper_bgcolor='#f8f9fa',
@@ -458,7 +468,6 @@ def create_cost_efficiency_scatter(df: pd.DataFrame) -> go.Figure:
458
  )
459
 
460
  # Add grid for better readability
461
- fig.update_xaxes(showgrid=True, gridwidth=1, gridcolor='lightgray')
462
  fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor='lightgray')
463
 
464
  return fig
 
432
  font=dict(size=20)
433
  )
434
 
435
+ # Calculate axis ranges for proper log scale display
436
+ min_cost = model_stats['total_cost_usd_display'].min()
437
+ max_cost = model_stats['total_cost_usd_display'].max()
438
+
439
  fig.update_layout(
440
  title={
441
  'text': '💰 Cost-Performance Efficiency',
 
446
  xaxis_title='Total Cost (USD)',
447
  yaxis_title='Success Rate (%)',
448
  xaxis_type='log', # Log scale for cost
449
+ xaxis=dict(
450
+ range=[np.log10(min_cost * 0.5), np.log10(max_cost * 2)], # Explicit log range
451
+ showgrid=True,
452
+ gridwidth=1,
453
+ gridcolor='lightgray'
454
+ ),
455
  height=600,
456
  plot_bgcolor='white',
457
  paper_bgcolor='#f8f9fa',
 
468
  )
469
 
470
  # Add grid for better readability
 
471
  fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor='lightgray')
472
 
473
  return fig