Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,25 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import plotly.express as px
|
|
|
4 |
|
5 |
# Function to plot the map
|
6 |
def plot_map(data):
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
return fig
|
11 |
|
12 |
# Streamlit app
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import plotly.express as px
|
4 |
+
import plotly.graph_objects as go
|
5 |
|
6 |
# Function to plot the map
|
7 |
def plot_map(data):
|
8 |
+
# Create a choropleth map as a base
|
9 |
+
fig = px.choropleth(locations=data['State'], locationmode="USA-states", scope="usa")
|
10 |
+
|
11 |
+
# Add a scatter plot on top to show the corporation labels
|
12 |
+
for index, row in data.iterrows():
|
13 |
+
fig.add_trace(go.Scattergeo(
|
14 |
+
lon=[row['Longitude']],
|
15 |
+
lat=[row['Latitude']],
|
16 |
+
text=f"{row['Corporation']} - ${row['Revenue']}B",
|
17 |
+
mode='text',
|
18 |
+
))
|
19 |
+
|
20 |
+
# Set the title
|
21 |
+
fig.update_layout(title="Top Corporations by State in the United States")
|
22 |
+
|
23 |
return fig
|
24 |
|
25 |
# Streamlit app
|