plotly / plotly/plotly.R

scattermapbox non-circle marker symbols not shown in legend since v4.12.0

Open
#2,481 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

Since upgrading to plotly 4.12.0, only the "circle" symbol is rendered correctly in the legend for scattermapbox traces. Other marker symbols (e.g. "diamond", "square") are no longer displayed — the legend shows a blank entry for those.

v 4.12.0

Image

v 4.11.0

Image

(note that already in previuos versions, the non-circle markers were not shown on the canvas itself, but this was not an issue in our use case, because we only wanted to create the custom legend with the square markers)

reprex

library(plotly)

symbols_to_try <- c(
  "circle",
  "diamond",
  "square",
  "marker"
)

traces <- lapply(seq_along(symbols_to_try), function(i) {
  list(
    type       = "scattermapbox",
    mode       = "markers",
    lon        = i * 2,
    lat        = 51,
    name       = symbols_to_try[i],
    showlegend = TRUE,
    hoverinfo  = "name",
    marker     = list(
      color  = "steelblue",
      size   = 20,
      symbol = symbols_to_try[i]
    )
  )
})

p <- plotly_empty() |>
  layout(
    mapbox = list(
      style  = "carto-positron",
      center = list(lon = 5, lat = 51),
      zoom   = 3
    ),
    legend = list(x = 1, xanchor = "right", y = 1)
  ) |>
  config(displaylogo = FALSE)

for (tr in traces) {
  p <- add_trace(p,
    inherit    = FALSE,
    type       = tr$type,
    mode       = tr$mode,
    lon        = tr$lon,
    lat        = tr$lat,
    name       = tr$name,
    showlegend = tr$showlegend,
    hoverinfo  = tr$hoverinfo,
    marker     = tr$marker
  )
}

p

packageVersion("plotly")

Further info:

The legend (and markers on canvas) work fine with "scattergeo" or even "scatter", but it has other side-effects in our setting that makes the plot be drawn twice, even if setting the layout like

plotly::layout(
    plotly_object,
    geo = list(
      visible = FALSE,
      showframe = FALSE,
      showcoastlines = FALSE,
      showland = FALSE,
      showocean = FALSE
    )
  )

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied R reprex using scattermapbox traces and compare the legend behavior between plotly 4.11.0 and 4.12.0. Trace how marker symbols are passed through add_trace and inspect the scattermapbox legend handling; done means circle, diamond, square, and marker entries render correctly without affecting scattergeo or scatter behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, r
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.