Go Scattermapbox with different traces like markers and bubbles/size possible?


I have mutliple dataframes with different data which I plot using Plotly Go Scattermapbox. Everything works fine. I add the dataframes with fig.add_trace and enter also customdata in there to display it in the hover.

Now I have a new dataframe which has lat, lon, name and also some values showing me the amount of prices and I want to have a bubbles on the map indicating where the price is high or low with big or small bubbles. Is this possible to add as a additional trace on my existing map?

What I currently have is something like this:

import plotly.graph_objects as go

token = open(".mapbox_token").read() # you need your own token

fig = go.Figure(go.Scattermapbox(
    mode = "markers",
    lon = df1['lon'],
    lat = df1['lat'],
    marker = {'size': 13},
    text = df1['name']

    mode = "markers",
    lon = df2['lon'],
    lat = df2['lat'],
    marker = {'size': 13},
    text = df2['name']

    mapbox = {
        'accesstoken': token,
        'style': "streets", 'zoom': 0.7},
    showlegend = False)



like the size parameter in the first example here?

Unfortunately size doesnโ€™t work with Plotly Graph objects.

This is the linked example using plotly.graph_objects:

import plotly.graph_objects as go
import plotly.express as px             # just as data source

# get data source
df = px.data.carshare()

# create scatter
data = go.Scattermapbox(
        'color': df.peak_hour,
        'size': df.car_hours/100

# create figure
fig = go.Figure(data=data, layout={'mapbox':{'style': "open-street-map"}})

# show figure

I had to scale the values from df.car_hours due to the high values in this column.

Thanks I will try it. But in your provided link I canโ€™t find the code you posted.