# NOT RUN {
# pass any number of plotly objects to subplot()
p1 <- plot_ly(economics, x = ~date, y = ~uempmed)
p2 <- plot_ly(economics, x = ~date, y = ~unemploy)
subplot(p1, p2, p1, p2, nrows = 2, margin = 0.05)
# or pass a list
library(purrr)
economics_long %>%
split(.$variable) %>%
map(~ plot_ly(., x = ~date, y = ~value)) %>%
subplot(nrows = NROW(.), shareX = TRUE)
# or pass a tibble with a list-column of plotly objects
economics_long %>%
group_by(variable) %>%
do(p = plot_ly(., x = ~date, y = ~value)) %>%
subplot(nrows = NROW(.), shareX = TRUE)
# learn more at https://cpsievert.github.io/plotly_book/subplot.html
# }
Run the code above in your browser using DataLab