I am building a map using
plotly.graph_objects.Choroplethmapbox. It works just fine to create the map, but I am having an issue with the colorbar.
Because of the uneven distribution of the data, I am setting my break points for the color changes manually using the
colorscale property like this:
fig = go.Figure(go.Choroplethmapbox( geojson=geo_nuts_level3, locations=df_plot['nuts_id'], z=df_plot[settings['metric']], zmin=0, zmax=df_breaks[settings['metric']].max(), colorscale=[ [0, '#ccc'], [breaks[0.2], '#FFF304'], # Cadmium Yellow [breaks[0.4], '#FFAC00'], # Chrome Yellow [breaks[0.6], '#FF4654'], # Sunburnt Cyclops [breaks[0.8], '#E71827'], # Pigment Red [breaks[0.9], '#C064E0'], [breaks[0.95], '#9C51B6'], # Purple Plum [breaks[0.99], '#733381'], # Maximum Purple [1, '#000000'] ], colorbar=dict( orientation='h', ), ))
breaks are calculated before using
quantile() to have a good representation of the data in the map. Now my problem is that there are very few data points for the highest values, but they take almost all the space of the colorbar making it almost entirely black:
I have been searching for a while now for a way to change the appearance of the colorbar without changing the appearance of the colors in the map. But although I have read and tried a lot (for example
Tickformatstop), I haven’t found a way.
I was wondering if somebody could hint me in the right direction to know if there is a way to accomplish what I have described.