Roberta2024 commited on
Commit
0a584d5
·
verified ·
1 Parent(s): de06db8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -10
app.py CHANGED
@@ -112,35 +112,44 @@ if st.button("Fetch Restaurant Data"):
112
  # Group the data by region and sum the number of restaurants
113
  region_group = df.groupby("Region").size().reset_index(name='Count')
114
 
115
- # Plot enlarged pie chart with store names
116
  pie_chart = go.Figure(go.Pie(
117
  labels=region_group["Region"],
118
  values=region_group["Count"],
119
- textinfo="label+percent", # Include region and percentage
120
- hoverinfo="label+value", # Show region and count on hover
121
- textfont=dict(size=18), # Make text larger
122
- marker=dict(line=dict(color='#000000', width=2)) # Add a border to slices
123
  ))
124
 
125
  pie_chart.update_layout(
126
- height=600, # Increase the size of the chart
127
- margin=dict(t=0, b=0, l=0, r=0)
 
 
 
128
  )
129
  st.subheader("Restaurant Distribution by Region (Enlarged Pie Chart)")
130
  st.plotly_chart(pie_chart)
131
 
132
- # Plot bar chart with store counts
133
  bar_chart = go.Figure(go.Bar(
134
  x=region_group["Region"],
135
  y=region_group["Count"],
136
  text=region_group["Count"],
137
- textposition='auto'
 
138
  ))
139
 
140
  bar_chart.update_layout(
 
 
 
141
  height=400,
142
  margin=dict(t=50, b=50, l=50, r=50),
143
- title="Restaurant Count by Region"
 
 
144
  )
145
  st.subheader("Restaurant Count by Region (Bar Chart)")
146
  st.plotly_chart(bar_chart)
 
112
  # Group the data by region and sum the number of restaurants
113
  region_group = df.groupby("Region").size().reset_index(name='Count')
114
 
115
+ # Plot enlarged pie chart with custom colors and labels
116
  pie_chart = go.Figure(go.Pie(
117
  labels=region_group["Region"],
118
  values=region_group["Count"],
119
+ textinfo="label+percent",
120
+ hoverinfo="label+value",
121
+ textfont=dict(size=18),
122
+ marker=dict(colors=px.colors.qualitative.Set3, line=dict(color='#000000', width=2))
123
  ))
124
 
125
  pie_chart.update_layout(
126
+ title="Restaurant Distribution by Region",
127
+ title_x=0.5,
128
+ title_font=dict(size=24, family="Arial"),
129
+ height=600,
130
+ margin=dict(t=50, b=50, l=50, r=50)
131
  )
132
  st.subheader("Restaurant Distribution by Region (Enlarged Pie Chart)")
133
  st.plotly_chart(pie_chart)
134
 
135
+ # Plot bar chart with custom colors and labels
136
  bar_chart = go.Figure(go.Bar(
137
  x=region_group["Region"],
138
  y=region_group["Count"],
139
  text=region_group["Count"],
140
+ textposition='auto',
141
+ marker=dict(color=px.colors.qualitative.Set2)
142
  ))
143
 
144
  bar_chart.update_layout(
145
+ title="Restaurant Count by Region",
146
+ title_x=0.5,
147
+ title_font=dict(size=24, family="Arial"),
148
  height=400,
149
  margin=dict(t=50, b=50, l=50, r=50),
150
+ xaxis_title="Region",
151
+ yaxis_title="Number of Restaurants",
152
+ xaxis=dict(tickangle=-45)
153
  )
154
  st.subheader("Restaurant Count by Region (Bar Chart)")
155
  st.plotly_chart(bar_chart)