Iām trying to create a choropleth map using the States, and I want to highlight the states by Annual Mean Wage, the code mentioned below is just an adaptation of the code you get from Plotly. Can anyone please let me know where Iām going wrong with this?
#import plotly
#from plotly.graph_objs import Scatter, Figure, Layout
#from plotly.offline import download_plotlyjs, init_notebook_mode, plot,iplot
import dash
import dash_core_components as dcc
import dash_html_components as html
data=pd.read_csv('/Users/harish/Downloads/SOC_Wage_plotly.txt',sep=',')
#data.head(10)
#data.dtypes
#data.replace('*','')
#data.replace('#','')
data.dropna()
for col in data.columns:
data[col]=data[col].astype(str)
data['text'] = data['state'] + '<br>' +\
'Mean Hourly wage'+data['mean_hourly_wage']+' Median Hourly wage '+data['median_hourly_wage']+'<br>'+\
'Annual Mean wage '+data['annual_mean_wage']
application=dash.Dash()
application.layout = html.Div([
dcc.Graph(
id='Annual_Mean_Wage_Map',
figure={
'data' : [ dict(
type='choropleth',
colorscale = [[0,"rgb(5, 10, 172)"],[0.35,"rgb(40, 60, 190)"],[0.5,"rgb(70, 100, 245)"],\
[0.6,"rgb(90, 120, 245)"],[0.7,"rgb(106, 137, 247)"],[1,"rgb(220, 220, 220)"]],
autocolorscale = False,
z = data['annual_mean_wage'].astype(float),
locations = data['state'].unique(),
locationmode = 'USA-states',
text = data['text'],
marker = dict(
line = dict (
color = 'rgb(255,255,255)',
width = 2
) ),
colorbar = dict(
title = "Annual Mean wage ")
) ],
"layout" :dict(
title = 'Wage statistics across the United States',
geo = dict(
scope='usa',
projection=dict( type='albers usa' ),
showlakes = True,
lakecolor = 'rgb(255, 255, 255)'),
)
}
)
])
if __name__ == '__main__':
application.run_server(debug=False)```
Any help, would be appraciated.
Thanks,
Harish