knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(cssgrid) library(ggplot2) library(dplyr, warn.conflicts = FALSE) library(purrr) library(plotly, warn.conflicts = FALSE)
plots <- diamonds %>% group_split(clarity) %>% map(~ { ggplot(.x) + aes(price, fill = clarity) + geom_density(show.legend = FALSE) + scale_fill_discrete(drop = FALSE) + labs(y = NULL) + theme_minimal() + facet_wrap(~ clarity) }) %>% map(plotly::ggplotly) %>% map(plotly::layout, showlegend = FALSE) %>% tagList
Change the window width and you'll see plots are re-arranged.
grid_layout(plots, auto_rows = "1fr", cols = "repeat(auto-fill, 6cm)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.