[英]DiagrammeR and R Markdown pdf: Remove space around diagram?
I've had quite some problems working with the package DiagrammeR in R Markdown with pdf specified as output. 我設法顯示了圖表,但正如您將在下面看到的那樣,圖表周圍有很多空間。
在這里查看我的示例代碼:
---
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.
此代碼生成以下 output:
請注意以下事項:
我該如何解決這些問題? 我喜歡這些軟件包,但是當 output 是 pdf 時可能很難使用? 也許其他包更好?
好問題。 我對markdown 塊選項進行了一些嘗試,並找到了以下解決方法來嵌入 png 而不是 pdf 圖:
---
title: "Untitled"
author: "test"
date: "14/05/2020"
output:
pdf_document:
keep_tex: yes
---
# My Markdown-file
This is my RMarkdown-file. Now I want to add a flowchart using the packages DiagrammeR.
```{r echo=FALSE, fig.cap = "Flowchart 1: Some explanation", dev='png'}
library("DiagrammeR")
grViz("
digraph test {
node [shape = circle]
A, B
A -> B
}
")
```
I now continue writing.
Cairo_PDF
等其他設備也可以正常工作,但不如預期的那樣,只是生成了一個 png。 我留下了keep_tex
選項以方便調試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.