fdaudens HF Staff commited on
Commit
8c334c1
·
verified ·
1 Parent(s): 0dae655

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -22
app.py CHANGED
@@ -106,36 +106,39 @@ def create_stats_html():
106
  type_dist['model_type'] = type_dist['model_type'].str.capitalize()
107
 
108
  # Create bar chart with better formatting
109
- fig_types = px.bar(
110
- type_dist,
111
- x='model_type',
112
- y='downloads_30d',
113
- title='Downloads by Model Type',
114
- labels={
115
- 'downloads_30d': 'Downloads (last 30 days)',
116
- 'model_type': 'Model Type'
117
- },
118
- text=type_dist['downloads_30d'].apply(format_number) # Add value labels
119
- )
120
 
121
- # Update layout for better readability and fix y-axis
122
- fig_types.update_traces(textposition='outside')
123
  fig_types.update_layout(
124
- uniformtext_minsize=8,
125
- uniformtext_mode='hide',
126
- xaxis_tickangle=0,
127
- yaxis_title="Downloads",
 
 
 
 
 
 
 
128
  plot_bgcolor='white',
129
  bargap=0.3,
130
- yaxis=dict(
131
- type='log', # Use log scale for better visualization
132
- range=[0, np.log10(type_dist['downloads_30d'].max() * 1.2)], # Add some padding at the top
133
- )
134
  )
135
 
136
  else:
137
  # Create empty figure if no data
138
- fig_types = px.bar(title='No data available')
139
 
140
  # Create top models table
141
  if len(derivative_df) > 0:
 
106
  type_dist['model_type'] = type_dist['model_type'].str.capitalize()
107
 
108
  # Create bar chart with better formatting
109
+ fig_types = go.Figure()
110
+
111
+ # Add bars
112
+ fig_types.add_trace(go.Bar(
113
+ x=type_dist['model_type'],
114
+ y=type_dist['downloads_30d'],
115
+ text=type_dist['downloads_30d'].apply(format_number),
116
+ textposition='outside',
117
+ ))
 
 
118
 
119
+ # Update layout
 
120
  fig_types.update_layout(
121
+ title='Downloads by Model Type',
122
+ yaxis_type="log", # Set y-axis to log scale
123
+ yaxis=dict(
124
+ title="Downloads",
125
+ type='log',
126
+ dtick=1, # This controls the tick spacing
127
+ tickformat=".1s" # Format ticks with K, M suffix
128
+ ),
129
+ xaxis=dict(
130
+ title="Model Type"
131
+ ),
132
  plot_bgcolor='white',
133
  bargap=0.3,
134
+ height=600,
135
+ showlegend=False,
136
+ margin=dict(t=100, b=50) # Add margin for labels
 
137
  )
138
 
139
  else:
140
  # Create empty figure if no data
141
+ fig_types = go.Figure()
142
 
143
  # Create top models table
144
  if len(derivative_df) > 0: