更新答案
现在,如果您想生成扩展屏幕整个宽度的选项卡集,请将.panel-tabset
div 与.column-screen
div.
请注意,我们必须使用更多:
for .column-screen
比.panel-tabset
分区我们用了三个:
for .panel-tabset
,所以我们必须再使用四个:
为以下内容创建 divcolumn-screen
.
---
title: "Panel tabs"
format: html
---
```{r}
library(tidyverse)
data <- iris %>% as_tibble()
plots <- data %>%
group_nest(Species) %>%
deframe() %>%
map(., ~ {
ggplot(.x, aes(x = Sepal.Length, y = Sepal.Width)) +
geom_point() +
theme_bw(
base_size = 18 # to increase the size of the plot elements
)
})
```
# Iris Plots
:::: {.column-screen}
::: {.panel-tabset}
```{r}
#| results: asis
#| fig-width: 14
#| fig-height: 6
iwalk(plots, ~ {
cat('## ', .y, '\n\n')
print(.x)
cat('\n\n')
})
```
:::
::::
Now the 面板选项卡扩展到屏幕的宽度。
另请注意,我增加了绘图元素的大小(例如 axis.title、axis.text 等)base_size = 18
在情节主题中。
旧答案
如果您只是删除column: screen
and fig-align: center
来自块选项。
因为这两个块选项正在阻止.panel-tabset
正确创建用于渲染选项卡集的 div。
因此,在删除这两个块选项后,这才有效(并且您不需要fig-align: center
因为选项卡集中的数字默认居中。
# Iris Plots
::: {.panel-tabset}
```{r}
#| fig-width: 12
#| fig-height: 8
#| results: asis
iwalk(plots, ~ {
cat('## ', .y, '\n\n')
print(.x)
cat('\n\n')
})
```