r - RMarkdown flexdashboard vertical_scroll 不适用于 facet_wrap
问题描述
我希望 flex 仪表板占据全屏(全宽、全高)并滚动以适应刻面环绕中的大量图。使用下面提供的 nycflights13 使我的问题可重现,并产生不可读的超级垂直压缩图。如何在 flex 仪表板中实现这一点?
下面的针织输出:https ://imgur.com/a/LyfZTw3
---
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
```
推荐阅读
- python - Pyspark 数据框:将 jdbc 写入具有给定模式的表的动态创建
- linux - 关于 anaconda 的 Linux 环境变量设置
- visual-studio-code - VS代码如何在鼠标悬停时显示完整的打字稿定义
- amazon-web-services - Amazon Chime 开发工具包 | SQS通知详细解析
- javascript - jQuery 滚动延迟(滞后)在 chrome 上但在 Firefox 上平滑
- clojurescript - 无法在试剂中添加背景图像
- sql-server - Perl 脚本无法使用 ODBC 连接到 MS SQL:“连接字符串无效”
- model-view-controller - Kendo NumericTextBox 不接受 Unicode 数字(来自其他语言的数字)
- android - 在android studio中为图像添加自定义水印
- git - Azure Devops Server:如何设置构建管道以将 git 源作为任务而不是自动获取