Spaces:
Sleeping
Sleeping
import streamlit as st | |
import geopandas as gpd | |
import matplotlib.pyplot as plt | |
# Function to plot the map with labels | |
def plot_map(): | |
us_map = gpd.read_file('path_to_shapefile.shp') | |
corporations_data = { | |
'Minnesota': [('CorpA', 100), ('CorpB', 50)], | |
'California': [('TechCorp', 300), ('HealthCorp', 200)], | |
# Add more states and corporations as needed | |
} | |
us_map.plot() | |
for state, data in corporations_data.items(): | |
geometry = us_map[us_map['STATE_NAME'] == state].geometry.iloc[0] | |
centroid = geometry.centroid | |
for i, (corp, revenue) in enumerate(data): | |
plt.text(centroid.x, centroid.y - i * 0.1, f'{corp}: ${revenue}B', fontsize=10) | |
plt.axis('off') | |
plt.show() | |
# Streamlit app | |
st.title('Top Corporations by State in the United States') | |
st.write('This map shows the top 2 corporations in each state with their revenue in billions of dollars for 2021.') | |
plot_map() | |