plotly / plotly.R

An interactive graphing library for R
https://plotly-r.com
Other
2.55k stars 625 forks source link

dynamicticks = T & faceting #1416

Open Hovav-Dror opened 5 years ago

Hovav-Dror commented 5 years ago

Trying facet_wrap with a categorical y axis and dynamicTicks =TRUE ends in: Error in tickvals - val : non-numeric argument to binary operator

ggplot is OK, only ggplotly returns the problem

Ideas?

db <- data_frame(
  x = c("a1", "b", "c1", "a2", "b", "c2"),
  Var = c("a", "a", "a", "b", "b", "b"),
  n = c(70, 50, 30, 30, 50, 70)
)
p <- db %>% 
  ggplot(aes(x = reorder(x,n), y = n)) +
  geom_col() +
  coord_flip()  +
  facet_wrap(~Var, scales = "free")
p
ggplotly(p, dynamicTicks = TRUE)

Now, if you wonder why I want to use dynamicTicks in the first place, see this example:

db <- data_frame(
  s = paste0(sample(LETTERS, 2000, replace = T), sample(LETTERS, 2000, replace = T)),
  x = sample(s[1:100], 2000, replace = T)
)

db %>% count(x, sort = T) %>% 
  ggplot(aes(x = reorder(x,n), y = n)) +
    geom_col() +
  coord_flip()

ggplotly(dynamicTicks = TRUE)
cpsievert commented 5 years ago

Thanks for the report!

rpollack commented 4 years ago

Just a bump. I'm also experiencing this issue.

homer3018 commented 3 years ago

+1