How to add Marker to Density Mapbox?

I want to put some markers on the Density Mapbox. I tried below, but no luck.
Can someone help me?

import pandas as pd
df = pd.read_csv('')

import as px
import plotly.graph_objects as go

fig = px.density_mapbox(df, lat='Latitude', lon='Longitude', z='Magnitude', radius=10,
                        center=dict(lat=0, lon=180), zoom=0,

        38.897957,  # White House   
        48.858093,  # Eiffel Tower
    marker= {'size': 20, 'symbol': ["diamond"]},

Hi @tsuga324

You are not able to combine Plotly express plots and graph objects together. Graph objects would provide flexibility over designing and hence would be best when you want to do more complex things. Plotly express allow you to do some quick plots in an aesthetic fashion.

I have placed an example here using the same code above but I am leaving the symbol to be the default one which is the circle.

import pandas as pd
import as px
import plotly.graph_objects as go

df = pd.read_csv('')

raw_symbols = SymbolValidator().values

fig = go.Figure(
            lon = df['Longitude'],
            z = [10],
            radius = 10,

fig.update_layout(mapbox_style="stamen-terrain",height = 700,
                  mapbox = {
                          'center': {'lat': 0, 
                          'lon': 180}

        marker={'size': 50 },

For a custom symbol it is not that easy and I think you need a mapbox token to have it working.

  • symbol
    Code: fig.update_traces(marker_symbol=<VALUE>, selector=dict(type='scattermapbox'))
    Type: string or array of strings
    Default: "circle" Sets the marker symbol. Full list: Note that the array marker.color and marker.size are only available for β€œcircle” symbols.

You can check out this page as well where there is an inbuilt package for symbols. Styling Markers | Python | Plotly

Do experiment them and improve the answer.

Let’s see if someone else can help with modification of this code.

Thank you! It works for me!

1 Like