Choropleth map in dash

Thanks @jack

I found out what was my problem and why the render was so slow on my side. I ll explain here, this might help some other users.

When I was adding the data in my figure, I was appending the data point by point:

for index, row in dff.iterrows():
    data_point = dict(
        type='scattermapbox',
        lat=row['lat'],
        lon=row['lon'],
        text=texthover,
        name=row['name'],
        customdata=[row['name']],
    )
    data.append(data_point)

Apparently, doing this way is extremely much slower than adding point as a batch

data.append(
    dict(
        type='scattermapbox',
        lat=dff['lat'].values,
        lon=dff['lon'].values,
        text=dff['text_hover'].values,
        name=dff['name'].values,
        customdata=dff['name'].values,
    )
)

I didn’t dig much to figure out why. I just add to manipulate the dataframe properly to avoid having to add the points one by one.

Hope this help someone.

This post is very popular and comes up on google, so I just wanted to share the latest and best resource: In the fall, we released a proper GeoJSON choropleth chart type called choroplethmapbox, see https://plotly.com/python/choropleth-maps/ for more examples.