GGPLOT - facet_wrap

Wraps a 1d sequence of panels into 2d and then convert them with ggplotly.

p <- ggplot(mpg, aes(displ, hwy)) + geom_point()
p <-  p + facet_wrap(vars(class))
plotly::ggplotly(p)
p <- ggplot(mpg, aes(displ, hwy)) + geom_point()
p <-  p + facet_wrap(vars(class), nrow = 4)
plotly::ggplotly(p)
p <-    
 ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  facet_wrap(vars(cyl, drv))
plotly::ggplotly(p)
p <-    
 ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  facet_wrap(vars(cyl, drv), labeller = "label_both")
plotly::ggplotly(p)
mpg$class2 <- reorder(mpg$class, mpg$displ)
p <-  ggplot(mpg, aes(displ, hwy)) +
p <-    geom_point() +
p <-    facet_wrap(vars(class2))
plotly::ggplotly(p)
p <-    
 ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  facet_wrap(vars(class), scales = "free")
plotly::ggplotly(p)
p <-    
 ggplot(mpg, aes(displ, hwy)) +
  geom_point(data = transform(mpg, class = NULL), colour = "grey85") +
  geom_point() +
  facet_wrap(vars(class))
plotly::ggplotly(p)
p <-    
 ggplot(economics_long, aes(date, value)) +
  geom_line() +
  facet_wrap(vars(variable), scales = "free_y", nrow = 2, strip.position = "top") +
  theme(strip.background = element_blank(), strip.placement = "outside")
plotly::ggplotly(p)