Black Lives Matter. Please consider donating to Campaign Zero's mission of ending police violence in America.

Plotly Express multiple plots overlay

If I want to have two plotly express figures plotted on the same axis. What should I do.

I tried this:

fig = px.scatter_mapbox(points, lat="ycoord", lon="xcoord")
fig.add_trace(px.scatter_mapbox(stations, lat="ycoord", lon="xcoord",))

But it is not working. I have two points dataset and want to see both on the same map.

Hi @shakasom, welcome to the forum! plotly express functions return a figure object (with data and layout). So, to add a trace to your existing figure created by plotly express, you can either

fig.add_trace(px.scatter_mapbox(stations, lat="ycoord", lon="xcoord",).data[0])
1 Like

Thanks @Emmanuelle. I understood and successfully used the second option. You add the trace with and by the way I stumbled upon that colors and markers can be changed using That was cool.

1 Like