knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(cssgrid)
library(ggplot2)
library(dplyr, warn.conflicts = FALSE)
library(purrr)
library(plotly, warn.conflicts = FALSE)

Prepare plots

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

Print plots with CSS Grid Layout with auto-fill

Change the window width and you'll see plots are re-arranged.

grid_layout(plots, auto_rows = "1fr", cols = "repeat(auto-fill, 6cm)")


atusy/cssgrid documentation built on June 24, 2019, 5:08 p.m.