【发布时间】:2020-08-30 19:05:08
【问题描述】:
我在使用 R Markdown 中的包 DiagrammeR 并将 pdf 指定为输出时遇到了很多问题。我设法显示了图表,但正如您将在下面看到的那样,图表周围有很多空间。
在这里查看我的示例代码:
---
title: "Untitled"
author: "test"
date: "14/05/2020"
output: pdf_document
---
# My Markdown-file
This is my RMarkdown-file. Now I want to add a flowchart using the packages DiagrammeR.
```{r figure_1, echo = FALSE, fig.align='center', fig.cap = "Flowchart 1: Some explanation"}
DiagrammeR::grViz("
digraph test {
node [shape = circle]
A; B
A -> B
}
")
```
I now continue writing.
此代码产生以下输出:
注意以下几点:
- 即使我在代码块中指定了图表不居中,也没有居中。
- 图表和标题之间存在巨大差距。
如何解决这些问题?我喜欢这些软件包,但是当输出为 pdf 时可能很难使用?也许其他包更好?
【问题讨论】:
-
也许看看 gmisc 包作为替代方案?
-
在非 Windows 系统上,如果存在
pdfcrop实用程序,则默认裁剪 PDF 图形。请参阅?rmarkdown::pdf_document参数fig_crop。如果您不在 Windows 上,请确保pdfcrop在您的路径上。如果你在 Windows 上,事情就更难了:knitr甚至不会尝试运行它。抱歉,我不在 Windows 上,因此无法为您提供有关如何解决此问题的详细说明。
标签: r pdf-generation r-markdown diagrammer