-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
responsive.Rmd
52 lines (45 loc) · 1.09 KB
/
responsive.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
title: "Responsive designs with cssgrid"
output:
rmarkdown::html_vignette:
self_contained: FALSE
vignette: >
%\VignetteIndexEntry{Responsive designs with cssgrid}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup-knit, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{r setup}
library(cssgrid)
library(ggplot2)
library(dplyr, warn.conflicts = FALSE)
library(purrr)
library(plotly, warn.conflicts = FALSE)
```
# Prepare plots
```{r prepare, items, cache = TRUE}
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.
```{r print}
grid_layout(plots, auto_rows = "1fr", cols = "repeat(auto-fill, 6cm)")
```