Hide colorbar from px.choropleth

@adamschroeder

We have two posibilites to set colorscale:

trace= go.Choroplethmapbox(z=z,
                            locations=locations,
                            colorscale='Viridis',
                            colorbar=dict(thickness=20, ticklen=3),
                            geojson=jdata,
                            hoverinfo='all',
                            marker_line_width=0.1, marker_opacity=0.7)

In this case the showscale is set either via trace.update or fig.data[corresponding_index].update(showscale=False),
or fig.update_traces(showscale=False), when len(fig.data)=1.

  1. coloscale/colorbar are set in layout.coloraxis
trace= go.Choroplethmapbox(z=z,
                            locations=locations,
                            #colorscale='Viridis',
                            #colorbar=dict(thickness=20, ticklen=3),
                            coloraxis='coloraxis',
                            geojson=jdata,
                            hoverinfo='all',
                            marker_line_width=0.1, marker_opacity=0.7)
layout=go.Layout(width=700, height=600,
                coloraxis=dict(colorscale=mapbox,
                               colorbar=dict(thickness=20, ticklen=3))   

When the go.Figureclass was instantied
we perform this update to remove the colorscale:

fig.update_layout(coloraxis_showscale=False)
3 Likes