我希望 flex 仪表板占据全屏(全宽、全高(并滚动以在小平面包装中容纳大量绘图。 使用下面提供的nycflights13使我的问题可重现,并生成不可读的图,超级垂直压缩。 如何在 Flex 仪表板中实现此目的?
针织产量如下:https://i.stack.imgur.com/MSecw.jpg
---
title: "facet test"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
---
```{r setup, include=FALSE}
library(flexdashboard)
library(nycflights13)
library(tidyr)
library(dplyr)
library(ggplot2)
```
Column
-----------------------------------------------------------------------
### Chart A
```{r dfs and plots, include=FALSE, warning=FALSE, cache=FALSE}
df <- flights %>%
group_by(dest, time_hour) %>%
summarise(n = n()) %>%
ungroup()
sp <- ggplot(df, aes(x=time_hour, y=n)) + geom_line()
fr <- sp + facet_wrap(~ dest)
```
```{r facet, out.width = '100%', warning=FALSE, echo=FALSE, message=FALSE, error=TRUE}
fr
```
您可以尝试使用fig.height
和fig.width
选项。这为我提供了相当合理的输出:
---
title: "facet test"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
---
```{r setup, include=FALSE}
library(flexdashboard)
library(nycflights13)
library(tidyr)
library(dplyr)
library(ggplot2)
```
Column
-----------------------------------------------------------------------
### Chart A
```{r dfs and plots, include=FALSE, warning=FALSE, cache=FALSE}
df <- flights %>%
group_by(dest, time_hour) %>%
summarise(n = n()) %>%
ungroup()
sp <- ggplot(df, aes(x=time_hour, y=n)) + geom_line()
fr <-
sp +
facet_wrap(~ dest) +
theme(strip.text.x = element_text(size = 8))
```
```{r facet, echo=FALSE, error=TRUE, fig.height=20, fig.width=16, message=FALSE, warning=FALSE}
fr
```