Skip to content

[bug(?)] Markers not showing when changing symbol in Scattermapbox #891

Closed

Description

@HaraldHeitmann

I was trying to do a Scattermapbox with different marker symbols, and they didn't render, at first I thought it was a Dash problem, but then I reproduce the same problem without dash (just plotly).
You can find some code to reproduce the error in the following link:

stack overflow question

Activity

  1. cldougl commented on Dec 4, 2017

    @cldougl
    Member

    Hi there,
    You can find more options about setting the marker for scattermapbox here: https://plot.ly/python/reference/#scattermapbox-marker
    Note, this trace does not behave exactly like typical plotly.js scatter traces as it uses mapbox: https://www.mapbox.com/

  2. HaraldHeitmann commented on Dec 4, 2017

    @HaraldHeitmann
    Author

    Thank you!
    Just to clarify, the issue was that I was setting a color and a size, to a symbol which isn't a circle, so it wasn't working properly?

  3. cldougl commented on Dec 4, 2017

    @cldougl
    Member

    no problem, to help clarify:
    https://plot.ly/python/reference/#scattermapbox-marker-symbol: Sets the marker symbol. Full list: https://www.mapbox.com/maki-icons/ Note that the array marker.color and marker.size are only available for "circle" symbols.

    so the 2 issues you may be running into are:
    a. color and size are only available when symbol is set to circle.
    b. the typical "plotly" symbols, (ie: https://plot.ly/python/reference/#scatter-marker-symbol) are not available for this trace type, instead you can find options and further instructions at the mapbox link: https://www.mapbox.com/maki-icons/

  4. andreapiso commented on Oct 23, 2018

    @andreapiso

    I am not trying to set color and size but still the custom markers do not render when I select something else than the default, for example "diamond". Can we re-open this issue?

  5. joeflack4 commented on May 20, 2021

    @joeflack4

    Description

    I have same problem in R. I have a shiny app w/ mapbox, and a choropleth. When I add markers, I get discrete colors just fine, but two things I can't do:

    1. Not related to this issue: I can't get continuous color scale
    2. Related: I can't get symbols to show up

    Code

        fig = plot_mapbox()
        # POLYGONS
          fig = fig %>% add_sf(
            data=districts,
            split=~DISTRICT,
            color=~log10(get(
              input$multi_indicator_districts.selectors.colorBy)),
            alpha=0.7,
            showlegend=FALSE)
        fig = fig %>% add_trace(
          type='scattermapbox',
          mode='markers',
          data=facilities,
          x=~longitude,
          y=~latitude,
          # split=~tier,  # discrete colors; renders just fine
          symbol=~tier,
          alpha=0.9,
          showlegend=TRUE)
        
        fig = fig %>% layout(
          mapbox=list(
            zoom=4,
            style='open-street-map'))

    W/ symbols off, markers appear

    Screen Shot 2021-05-19 at 7 49 47 PM

    W/ symbols on, don't appear

    Strangely, it looks like it's also trying to color the symbols even though I'm not asking it to do so.
    Screen Shot 2021-05-19 at 9 06 25 PM

  6. dancassin commented on Jul 6, 2023

    @dancassin

    I know this is over two years later, but I had the same issue recently and found my solution. You have the wrong mapbox style selected. The mapbox symbols do not work with the "carto-positron" style or "open-street-map".

    In order for symbols to work, you need to use the following mapbox styles (in addition to having a free Mapbox account with a public key):

    • basic
    • streets
    • outdoors
    • light
    • dark
    • satellite
    • satellite-streets

    Reference
    https://plotly.com/python/scattermapbox/#set-marker-symbols

  7. Sajjad-Mahmoudi commented on Aug 24, 2023

    @Sajjad-Mahmoudi

    I know this is over two years later, but I had the same issue recently and found my solution. You have the wrong mapbox style selected. The mapbox symbols do not work with the "carto-positron" style or "open-street-map".

    In order for symbols to work, you need to use the following mapbox styles (in addition to having a free Mapbox account with a public key):

    • basic
    • streets
    • outdoors
    • light
    • dark
    • satellite
    • satellite-streets

    Reference https://plotly.com/python/scattermapbox/#set-marker-symbols

    It doesn't work. Only circle is rendered.

  8. joeflack4 commented on Aug 25, 2023

    @joeflack4

    I'm working on this project anymore but I can forward the solution if there is one.
    @Sajjad-Mahmoudi No luck, eh? Did you try every one of those options?

  9. Sajjad-Mahmoudi commented on Aug 25, 2023

    @Sajjad-Mahmoudi

    I'm working on this project anymore but I can forward the solution if there is one. @Sajjad-Mahmoudi No luck, eh? Did you try every one of those options? @joeflack4

    Hi, below is the code snippet:
    px.set_mapbox_access_token(my_token)
    fig = px.scatter_mapbox(data_frame=dff_exploded,
    lat="lat", lon="lon",
    zoom=6,
    mapbox_style="outdoors", # "basic", "outdoors", "satellite-streets", "light"
    # hover_name="facilities" + ": " + "n_trials",
    width=1500,
    height=700,
    hover_data={'lat': False, 'lon': False, 'facilities': True, 'n_trials': True},
    )
    fig.update_traces(cluster=dict(enabled=True,
    maxzoom=12,
    color='#FF3333',
    size=15,
    opacity=1,
    ),
    marker=dict(opacity=1,
    symbol='circle', # marker
    size=10,
    color='blue',
    ),
    hovertemplate="%{customdata[2]}: %{customdata[3]}"
    )
    So, I tried all the recommended solutions to change the marker from "circle" to "marker" and some others, but only "circle" marker is overlayed on the map.

  10. dancassin commented on Aug 25, 2023

    @dancassin

    Try removing the mapbox info from the original px.scatter_mapbox call. Also be sure the map_box style works with different symbols. Not all do. Also, not all of the symbols are currently working. I know "streets" and "triangle" work together, so I've included it below in an excerpt of my working code.

    fig.add_trace(
                    go.Scattermapbox(
                        lat=df.lat,
                        lon=df.lon,
                        customdata=df[["name", "address"]],
                        hovertemplate="%{customdata[0]}<br>%{customdata[1]}",
                        name="",
                        mode="markers",
                        marker=dict(
                            symbol="triangle",
                            size=8,
                        ),
                        showlegend=False,
                    ),
                )
    fig.update_layout(
                mapbox=dict(
                    accesstoken=mapbox_token,
                ),
                mapbox_style="streets",
            )
    
  11. gaardhus commented on May 28, 2024

    @gaardhus

    I think raising a warning for the user when they specify both symbol and color attributes for their markers would be a nice addition in this case.

  12. emilykl commented on Aug 31, 2026

    @emilykl
    Contributor

    This issue is already closed, but I just wanted to leave a note that Maki symbols should work smoothly in plotly.py v7.0.0 and above. See this comment for more information.

    Note that Mapbox traces have been replaced by Map traces. In most cases, replacing the word mapbox/Mapbox with map/Map everywhere it appears, and removing references to the Mapbox access token, should be all that's needed to migrate. See this docs page for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions