Black Lives Matter. Please consider donating to Black Girls Code today.

How to plot 2 legends on a Scattermapbox

Hi would like to know how can I show both scales(legends) on the side, when I turn on both showscale=True,
they overlap eachother.

Can someone provide guidance how to show both scales next to eachother? please refer to code layout below

Also how would I label the scales?

    ## heat density map
    fig_map = go.Figure()
    fig_map.add_trace(go.Densitymapbox(
        name='Density',
        lat=df_1.lat,
        lon=df_1.lon,
        z=df_1.av_lat_lon_gps_signal,
        radius=20,
        colorscale='tropic',
        zmax=10,
        zmid=0.2,
        zmin=0,
        text=df_1['label'],
        hovertemplate="%{text}",
        showscale=False,

    ))

    fig_map.update_layout(
        title=f'Standard Deviation Lat and Long',
        #autosize=True,
        height=1000,
        margin=dict(l=40, r=200, t=80, b=0),
        mapbox=go.layout.Mapbox(
            style='open-street-map',
            # bearing=0,
            center=go.layout.mapbox.Center(
                lat=-20.31,
                lon=118.63,
            ),
            pitch=0,
            zoom=12,
        )
    )



	fig_map.add_trace(go.Scattermapbox(
	lat=car_speed_df.lat,
	lon=car_speed_df.lon,
	mode='markers',
	marker=go.scattermapbox.Marker(
		size=10,
		color=car_speed_df.velocity,
		colorscale='RdBu_r',  # _r reverses the color scale
		opacity=0.9,
		showscale=False,

	),
	# text=car_speed_df.label,
	# hoverinfo='text'
	hovertext=car_speed_df.label,
	))

@Michael01,
Inside the density and scattermapbox definition you can set also the colorbar position:

colorbar_x=1.05 #for density

respectively
colorbar_x = -0.25 #for scattermapbox
These positions can be adjusted such that to avoid to get a colorbar overlaying the plot.

great thank you, it works.

I couldn’t find document information for this. Can you provide a location where I can find more info for other settings?

@Michael01,
When you need details on a trace or layout attribute, just open
[https://plot.ly/python/reference] (https://plot.ly/python/reference), and fill in the search box scattermapbox, for example. A list of attribute are listed and you can select one of them.
For example: [https://plot.ly/python/reference/#scattermapbox-marker-colorbar].
Here click on x and get open https://plot.ly/python/reference/#scattermapbox-marker-colorbar-x.

Similarly, you can write down in your Jupyter notebook or IDE:

help(go.Scattermapbox.marker)

then help(go.scattermapbox.Marker.colorbar)

and similarly:

help(go.Densitymapbox.colorbar)