awacke1 commited on
Commit
12138f7
·
1 Parent(s): 8a7220f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
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
- fig = px.choropleth(data, locations='State', locationmode="USA-states", color='Revenue',
8
- scope="usa", title="Top Corporations by State in the United States",
9
- hover_name='Corporation', hover_data=['Revenue'])
 
 
 
 
 
 
 
 
 
 
 
 
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