Skip to content

formula-driven symbol ?bug? #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timelyportfolio opened this issue Jul 20, 2016 · 0 comments
Closed

formula-driven symbol ?bug? #650

timelyportfolio opened this issue Jul 20, 2016 · 0 comments

Comments

@timelyportfolio
Copy link
Collaborator

timelyportfolio commented Jul 20, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant