Skip to content

formula-driven symbol ?bug? #650

Closed
Closed
@timelyportfolio

Description

@timelyportfolio

I discovered this as I was assembling this Plotly + statebins post. I am not convinced it is a bug yet, but it is certainly very confusing to me. While I experienced this behavior with symbol, I am guessing that it extends to other arguments, such as color, x, etc. If I had to choose I would say the behavior in the last example is closest to what I would expect, but of course using add_markers instead of the add_trace.

library(plotly)
df <- data.frame( x = 1:10 )

doesn't work

# doesn't work
df %>%
  plot_ly() %>%
  add_markers(
    x = ~x, y = ~x,
    symbol = ~1:nrow(df) > 5,
    symbols = c("triangle-down","triangle-up"),
    size = I(200)
  )

image

works

# works
df %>%
  plot_ly() %>%
  add_markers(
    x = ~x, y = ~x,
    symbol = c(rep("a",5),rep("b",5)),
    symbols = c("triangle-down","triangle-up"),
    size = I(200)
  )

image

works

# works
df %>%
  plot_ly() %>%
  add_markers(
    x = ~x, y = ~x,
    symbol = c(rep("triangle-down",5),rep("triangle-up",5)),
    symbols = c("triangle-down","triangle-up"),
    size = I(200)
  )

image

works

# works
df %>%
  plot_ly() %>%
  add_trace(
    x = ~x, y = ~x,
    type = "scatter",
    mode = "markers",
    marker = list(
      symbol = ~ifelse(1:nrow(df) > 5, "triangle-down", "triangle-up")
    ),
    size = I(200)
  )

image

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