Description
When assigning marker symbols on a go.Scattermap trace, the legend swatch for those
symbols is rendered inconsistently and often incorrectly. With identical trace config
(only marker.symbol changes) one of three things happens:
- Map icon renders, legend swatch is blank. The symbol draws correctly on the map,
but the legend swatch is empty i.e., the legend row and label are present, just no icon is
drawn. Happens for square and star.
- Map icon renders, legend swatch falls back to a plain circle. The symbol draws
correctly on the map, but the legend swatch is a plain circle in the marker's colour
(black here) instead of the assigned symbol. Seems to happen for most symbols, e.g.
triangle-stroked, marker, rocket.
- Symbol renders nowhere on the map; legend swatch blank (as in case 1). The symbol
draws nothing on the map, while the legend row is present with a blank swatch. Essentially like case 1, but the map marker is missing entirely (I have noticed this with diamond but haven't done an exhaustive check).
Expected: the legend swatch should consistently show the same symbol that's drawn on the
map (or at least behave the same way across symbols).
Screenshots/Video
(Ignore the legend title)
Interestingly if I don't provide color="black" I get multicoloured legend swatches:
Steps to reproduce
import plotly.graph_objects as go
# One marker per symbol, each its own legend row. Same config throughout — only the
# symbol differs. Observe the legend swatches vs. the map markers.
symbols = ["square", "triangle-stroked", "diamond"] # case 1, case 2, case 3
figure = go.Figure()
for index, symbol in enumerate(symbols):
figure.add_trace(
go.Scattermap(
lat=[52.5 + index * 0.05],
lon=[13.4 + index * 0.05],
mode="markers",
marker=dict(size=14, color="black", symbol=symbol),
name=symbol,
showlegend=True,
)
)
figure.update_layout(
map=dict(style="open-street-map", center=dict(lat=52.6, lon=13.5), zoom=8),
showlegend=True,
margin=dict(l=0, r=0, t=0, b=0),
)
figure.show()
Observed in the rendered legend:
square — map: square, legend: blank (case 1)
triangle-stroked — map: triangle, legend: plain black circle (case 2)
diamond — map: nothing, legend: blank (case 3)
Environment
- plotly: 6.7.0
- Python: 3.12.12
- Trace type:
go.Scattermap (MapLibre), base style open-street-map
Description
When assigning marker symbols on a
go.Scattermaptrace, the legend swatch for thosesymbols is rendered inconsistently and often incorrectly. With identical trace config
(only
marker.symbolchanges) one of three things happens:but the legend swatch is empty i.e., the legend row and label are present, just no icon is
drawn. Happens for
squareandstar.correctly on the map, but the legend swatch is a plain circle in the marker's colour
(black here) instead of the assigned symbol. Seems to happen for most symbols, e.g.
triangle-stroked,marker,rocket.draws nothing on the map, while the legend row is present with a blank swatch. Essentially like case 1, but the map marker is missing entirely (I have noticed this with
diamondbut haven't done an exhaustive check).Expected: the legend swatch should consistently show the same symbol that's drawn on the
map (or at least behave the same way across symbols).
Screenshots/Video
(Ignore the legend title)
Interestingly if I don't provide
color="black"I get multicoloured legend swatches:Steps to reproduce
Observed in the rendered legend:
square— map: square, legend: blank (case 1)triangle-stroked— map: triangle, legend: plain black circle (case 2)diamond— map: nothing, legend: blank (case 3)Environment
go.Scattermap(MapLibre), base styleopen-street-map