Hi , I have written a few lines of code to display the choropleth map for the US states , and on hover it displays some custom data statistics…but whati want to do is , i want is to display the values on the state itself on the map. Or to make the hover stay on all the time so i can see the stats, how is it possible with plotly express ?
I am sending the snippet
layout =html.Div([
html.Div([
html.Div( [dcc.Dropdown(id=‘measure-picker’,options=measure_options,value=‘ex_management_costs_per_1k_sqft’) ], className=“one-half column”),
html.Div( [dcc.Dropdown(id='building-type-picker',options=select_btype_options,value='condo',multi=False)], className="one-half column"),
], id="header",
className="row flex-display",
style={"margin-bottom": "5px"}),
html.Div( [ dcc.Graph(id='bm_scatter_map') ] , className=" column"),
html.Div( [ dcc.Graph(id='bm_scatter') ] , className=" column"),
])
@app.callback(Output(‘bm_scatter_map’, ‘figure’),
[Input(‘measure-picker’, ‘value’),
Input(‘building-type-picker’, ‘value’) ])
def get_map_state(selected_measure, building_type):
df = df_data_bm.round(0)
df = df[df['name'].str.contains(building_type)]
df['st']=df[['name']].apply(lambda x: x['name'].split('_')[0],axis=1).str.upper()
labels= df['st'].unique()
label_dic= {x : x for x in labels}
fig = px.choropleth(df, locations=df['st'], color=selected_measure,
locationmode="USA-states",
color_continuous_scale="RdYlGn_r",
#range_color=(0, 50),
labels=label_dic,
hover_data=['st','count'],
scope="usa")
fig.update_layout( margin={"r":0,"t":0,"l":0,"b":0} ,
showlegend = True,
height= 600,)
return fig