Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import geopandas as gpd
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
|
5 |
+
# Function to plot the map with labels
|
6 |
+
def plot_map():
|
7 |
+
us_map = gpd.read_file('path_to_shapefile.shp')
|
8 |
+
corporations_data = {
|
9 |
+
'Minnesota': [('CorpA', 100), ('CorpB', 50)],
|
10 |
+
'California': [('TechCorp', 300), ('HealthCorp', 200)],
|
11 |
+
# Add more states and corporations as needed
|
12 |
+
}
|
13 |
+
us_map.plot()
|
14 |
+
for state, data in corporations_data.items():
|
15 |
+
geometry = us_map[us_map['STATE_NAME'] == state].geometry.iloc[0]
|
16 |
+
centroid = geometry.centroid
|
17 |
+
for i, (corp, revenue) in enumerate(data):
|
18 |
+
plt.text(centroid.x, centroid.y - i * 0.1, f'{corp}: ${revenue}B', fontsize=10)
|
19 |
+
plt.axis('off')
|
20 |
+
plt.show()
|
21 |
+
|
22 |
+
# Streamlit app
|
23 |
+
st.title('Top Corporations by State in the United States')
|
24 |
+
st.write('This map shows the top 2 corporations in each state with their revenue in billions of dollars for 2021.')
|
25 |
+
plot_map()
|