fdaudens HF staff commited on
Commit
cc73002
·
verified ·
1 Parent(s): 8c334c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -24
app.py CHANGED
@@ -106,39 +106,35 @@ 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 = 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:
 
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', # x-axis: model types
112
+ y='downloads_30d', # y-axis: number of downloads
113
+ title='Downloads by Model Type',
114
+ labels={'downloads_30d': 'Downloads', 'model_type': 'Model Type'},
115
+ text=type_dist['downloads_30d'].apply(format_number)
116
+ )
 
117
 
118
+ # Update layout for log scale and better appearance
119
  fig_types.update_layout(
 
 
120
  yaxis=dict(
 
121
  type='log',
122
+ title='Downloads (log scale)'
 
 
 
 
123
  ),
 
 
 
124
  showlegend=False,
125
+ plot_bgcolor='white',
126
+ height=500,
127
+ width=800
128
+ )
129
+
130
+ # Update bars and text
131
+ fig_types.update_traces(
132
+ textposition='outside',
133
+ cliponaxis=False
134
  )
135
 
136
  else:
137
+ fig_types = px.bar(title='No data available')
 
138
 
139
  # Create top models table
140
  if len(derivative_df) > 0: