# How to customize markers in scatter\_mapbox?

**URL:** <https://community.plotly.com/t/how-to-customize-markers-in-scatter-mapbox/80089>\
**Category:** 📊 Plotly Python\
**Created:** [November 13, 2023, 2:05pm UTC](https://community.plotly.com/t/how-to-customize-markers-in-scatter-mapbox/80089 "2023-11-13T14:05:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sislvacl](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@sislvacl](https://community.plotly.com/u/sislvacl)\
**Post date:** [November 13, 2023, 2:05pm UTC](https://community.plotly.com/t/how-to-customize-markers-in-scatter-mapbox/80089/1 "2023-11-13T14:05:35Z")

</div>

Hello,

I’m looking at the [basic example for px.scatter\_mapbox](https://plotly.com/python/scattermapbox/#basic-example-with-plotly-express).

This is the provided code snippet:

```python
import plotly.express as px
px.set_mapbox_access_token(open(".mapbox_token").read())
df = px.data.carshare()
fig = px.scatter_mapbox(df, lat="centroid_lat", lon="centroid_lon", color="peak_hour", size="car_hours",
                  color_continuous_scale=px.colors.cyclical.IceFire, size_max=15, zoom=10)
fig.show()

```

Would it be possible to modify the markers by setting outline width and color?

I tried the following but with no success:

```python
fig.update_traces(
    marker=dict(
        line=dict(width=2, color='DarkSlateGrey'), # doesn't work
    )
)

```

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [November 13, 2023, 4:08pm UTC](https://community.plotly.com/t/how-to-customize-markers-in-scatter-mapbox/80089/2 "2023-11-13T16:08:19Z")

</div>

Hi @sislvacl ,

I think the marker symbols are different to the ones used in go.Scatter(), the help refers to these symbols: [Maki Icons | By Mapbox](https://labs.mapbox.com/maki-icons/)

There is a example in the docs however, which I adapted:

```python
import plotly.graph_objects as go
import plotly.express as px
import pandas as pd

df = pd.read_csv(
    "https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv"
)
fig = px.scatter_mapbox(
    df,
    lat="lat",
    lon="long",
    zoom=3,
    mapbox_style="open-street-map",
    )
    
fig.update_traces(
    marker=go.scattermapbox.Marker(
            size=14,
            color='rgb(0, 0, 255)',
            opacity=1.0
        )
    )
    
fig.add_trace(
    go.Scattermapbox(
        lat=df.lat,
        lon=df.long,
        mode='markers',
        marker=go.scattermapbox.Marker(
            size=8,
            color='rgb(255, 0, 0)',
            opacity=1.0
        ),
        hoverinfo='none'
    )
)

```

Basically you are plotting the same data twice with different marker sizes (and colors) to obtain the visual effect of a line.

Here the original [example](https://plotly.com/python/scattermapbox/):

> **Example**
>
> ```python
> import plotly.graph_objects as go
> import pandas as pd
> 
> mapbox_access_token = open(".mapbox_token").read()
> 
> df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/Nuclear%20Waste%20Sites%20on%20American%20Campuses.csv')
> site_lat = df.lat
> site_lon = df.lon
> locations_name = df.text
> 
> fig = go.Figure()
> 
> fig.add_trace(go.Scattermapbox(
> lat=site_lat,
> lon=site_lon,
> mode='markers',
> marker=go.scattermapbox.Marker(
> size=17,
> color='rgb(255, 0, 0)',
> opacity=0.7
> ),
> text=locations_name,
> hoverinfo='text'
> ))
> 
> fig.add_trace(go.Scattermapbox(
> lat=site_lat,
> lon=site_lon,
> mode='markers',
> marker=go.scattermapbox.Marker(
> size=8,
> color='rgb(242, 177, 172)',
> opacity=0.7
> ),
> hoverinfo='none'
> ))
> 
> fig.update_layout(
> title='Nuclear Waste Sites on Campus',
> autosize=True,
> hovermode='closest',
> showlegend=False,
> mapbox=dict(
> accesstoken=mapbox_access_token,
> bearing=0,
> center=dict(
> lat=38,
> lon=-94
> ),
> pitch=0,
> zoom=3,
> style='light'
> ),
> )
> 
> fig.show()
> 
> ```
