Skip to content

Scattermapbox maki symbols plot on map, but not legend #2965

Open

Description

@Charlesfox1

Hi Plotly,

First, thank you for all the fantastic work you do.

I am a big fan of / heavy user of the plotly.go objects that render maps (Scattermapbox / Choroplethmapbox).

I have noticed, however, that when setting the symbol type to a maki symbol, it will render it on the map - but not the legend. This feels like a bug, as there is also a colour associated with the legend item that is not matched anywhere on the plot / by the symbol (except in hovertext).

Reproducible example below:

import os
import plotly.graph_objects as go

mapboxt = os.getenv('MAPBOX_TOKEN') # a mapbox token

lats = [52.370216, 53.2191696,  50.851368, 51.8125626]
lons = [4.895168,  6.5666699, 5.690973, 5.8372264 ]

fig = go.Figure()

scatt = go.Scattermapbox(
            lat=lats,
            lon=lons,
            mode='markers',
            hovertext=['Amsterdam', 'Groningen',  'Maastricht', 'Nijmegen'],  
            hoverinfo='text',                 
            below='',                 
            marker=dict(symbol ='hospital'),
            name ='my_fake_hospitals',
            showlegend=True)

fig.add_trace(scatt)

fig.update_layout(go.Layout(title_text ='Is it a hospital? No, it is a blue dot!', 
                            title_x=0.5, 
                            width=750, 
                            height=700,
                            mapbox = dict(center= dict(lat=52.370216, lon=4.895168),            
                                         accesstoken= mapboxt,
                                         zoom=5,
                                         style="light"
                                       )))

fig

Finally, as a side note, some maki symbols plot whilst others do not. I have determined through trial and error that this is down to whether or not the MapBox style includes these specific symbol types. Using custom Mapbox styles, therefore, may silently break the maki functionality as well.

Thanks you for your attention.

Activity

  1. self-assigned this
    on Jun 24, 2024
  2. FlorianJacta commented on Jul 29, 2024

    @FlorianJacta

    What worked for you?

  3. removed their assignment
    on Aug 2, 2024
  4. changed the title [-]Bug report: Scattermapbox: maki symbols plot on map, but not legend[/-] [+]Scattermapbox maki symbols plot on map, but not legend[/+] on Aug 12, 2024
  5. emilykl commented on Aug 31, 2026

    @emilykl
    Contributor

    Hi @Charlesfox1, I apologize that this issue never got a response!

    I just wanted to note that this has been fixed in plotly.py v7.0.0, sort of.

    In plotly/plotly.js#7825 we resolved a bug which prevented Maki icons from being colored. Now, they have a color which matches the dot in the legend. This looks best if you set marker.size to a larger value such as 14, resulting in a plot that looks something like this:

    Image

    We still don't use icons in the legend, though; I did look into it but it's a bit complex since the Maki icons are loaded on-demand. It could be implemented in the future though.

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

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions