7

我在用 Rstudio 编译的 Rmd 报告中使用美人鱼图。在 HTML/PDF 输出中,图表上方和下方有很多空白,请参见下面的示例。

# Header
Text
```{r}
library(DiagrammeR)
mermaid("
graph TD
    classDef style_main_node fill:orange,stroke:#333,stroke-width:0px;
    classDef style_sub_node fill:lightgray,stroke:#333,stroke-width:0px;

0(Top)
0 --> A1(Left)
0 --> B1(Center)
0 --> C1(Right)

    class 0 style_main_node;
    class A1,B1,C1 style_sub_node;
")
```
Text

HTML 输出:使用美人鱼图渲染 Rmd

有没有办法裁剪/调整图表周围的空白?还可能改变它的大小?

4

1 回答 1

3

只需指定图表周围的高度和宽度:height = '100%', width = '100%'

# Header
Text
```{r}
library(DiagrammeR)
mermaid("
graph TD
    classDef style_main_node fill:orange,stroke:#333,stroke-width:0px;
    classDef style_sub_node fill:lightgray,stroke:#333,stroke-width:0px;

0(Top)
0 --> A1(Left)
0 --> B1(Center)
0 --> C1(Right)

    class 0 style_main_node;
    class A1,B1,C1 style_sub_node;
", height = '100%', width = '100%')
```
Text

在此处输入图像描述

于 2019-12-19T12:13:19.677 回答