✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Update legend labels

Hello,

I have been able to plot both my points of interest and regions on a single map (i.e. scatter map and choropleth). The legend is correctly labeled for the regions in my choropleth, but the scatter map shows ‘trace 3’. Can someone let me know how I can change the label?

Here is my code:

fig = go.Figure()

for i, cluster in enumerate(df['Cluster'].unique()):
    dfp = df[df['Cluster'] == cluster]
    fig.add_choroplethmapbox(geojson=counties, 
                             locations=dfp['FIPS'],
                             z=[i,] * len(dfp), 
                             showlegend=True, 
                             name=cluster,
                             colorscale=colorscales[i], 
                             showscale=False)

fig.add_trace(go.Scattermapbox(
        lat=site_lat,
        lon=site_lon,
        mode='markers',
        marker=go.scattermapbox.Marker(
            size=5,
            color='rgb(0, 128, 0)',
            opacity=0.3
        ),
        text=locations_name,
        hoverinfo='text'
    ))

fig.update_layout(geo_scope='usa',
                  mapbox=dict(style="carto-positron", zoom=3,center={"lat": 37.0902, "lon": -95.7129},
                              ))


fig.show()