I want to draw an outline highlighting a shape in a Choropleth map drawn from a GeoJSON using Plotly (in my case over Dash).
I have a dataframe "df" like this one:
state (string) value (float)
STATE_1 50.0
STATE_2 30.5
STATE_3 66.2
I have also a GeoJSON loaded as an object with this structure:
{
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'id': 1,
'properties': {
'id': 'STATE_1',
},
'geometry': {'type': 'Polygon', 'coordinates': [...]},
},
...
]
}
I've drawn my base map like this:
fig = px.choropleth(
df,
geojson=my_geojson,
color='value',
locations='state',
featureidkey='properties.id',
projection='Mercator',
)
fig.update_geos(
fitbounds='locations',
visible=False,
)
fig.update_layout(
coloraxis=dict(
colorbar=dict(
title='',
orientation='h',
x=0.5,
y=0.1,
xanchor='center',
yanchor='top',
),
colorscale=[[0, '#04cc9a'], [1, '#5259ad']],
),
margin={"r": 0, "t": 0, "l": 0, "b": 0},
dragmode=False,
)
I've tried to add another trace unsuccessfully to show the outline of one of the states. I've tried it both using plotly express and plotly graph objects with no results.
How should I do it?
