Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Add a color border to a specific polgygon in a plotly choropleth map

$
0
0

I plotted a choroplethmap with the following code:

fig = px.choropleth_mapbox(df,
                           geojson=df.geometry,
                           locations=df.index,
                           color="valu1",
                           color_continuous_scale='RdBu',
                           mapbox_style="open-street-map",
                           zoom=8)


fig.show()

Which returned this map:

image

So what I want is to set the edge color of a specific polygon that meets one condition. May be df.index=1(or any index) or df[df[‘column_name’]=='any_cell_value"] but I’m not being able to do it.

I tried out this:

fig.for_each_trace(
    lambda trace: trace.update(marker_line_color="green") if selector==dict(column_name='any_cell_value') else (),
)

But it added green borders to all polygons. And I also tried out add_choroplethmapbox but I’m getting several errors.

How could I do what that? Any ideas? Thank you!

4 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles