plotly / plotly/plotly.py

Scattermapbox maki symbols plot on map, but not legend

Offen
#2,965 2 Kommentare 12 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P3
Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie damit, das bereitgestellte reproduzierbare Python-Beispiel mit Scattermapbox, dem Maki-Symbol "hospital" und showlegend=True auszuführen, und vergleichen Sie dann das Kartensymbol mit seinem Legendeneintrag. Verfolgen Sie die Handhabung von Scattermapbox-Marker-Symbolen und der Legende, einschließlich des Hinweises zu Mapbox-Stilen; als abgeschlossen gilt die Aufgabe, wenn unterstützte Maki-Symbole konsistent in der Legende und auf der Karte erscheinen und das Verhalten durch einen Regressionstest abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.