0

I am using DiagrammeR::grViz in R Markdown to build a flowchart. However, I couldn't find out how to control the distance between the flow chart and the margins of the diagram. Here is my YAML, very simple:

title: Very good title
author: "Mr author"
date: "`r Sys.Date()`"
output:
  word_document: 
    reference_docx: template.docx

and the setup chunk:

{r setup}
library(DiagrammeR)
knitr::opts_knit$set(root.dir= normalizePath('..'), echo = F)
knitr::opts_chunk$set(error = F, echo = F, warning = F, fig.width=8, fig.height=6)

and here is my code in a markdown chunk

{r echo = F}
DiagrammeR::grViz("
digraph StudyFC {graph [layout = dot, fontsize = 12]
# node definitions with substituted label text
node [shape = rectangle, fillcolor = Biege]
total [label = '@@1']
excluded [label = '@@2 \n \n @@3']
final [label = '@@4']
total -> excluded -> final
}

")

The distance marked with the red file is what I want to control: grViz Outcome

And this is what I am looking for: Flowchart

ebay
  • 109
  • 1
  • 7
  • What are you expecting please. I know you want to remove the whitespace but if you are placing the figure in a document, it will likely have space to the side of the page. But you can just reduce the width of the plot / output device. Might be worth showing a very minimal markdown doc of how you are using this and what is expected. – user20650 Mar 06 '21 at 14:22
  • @user20650 Thanks for response. I have uploaded a graph with what I am expecting. It has nothing to do with word or the final document. The graph is already being presented like this after I run the code in Rmarkdown. I have added my YAML and some parts of my markdown. – ebay Mar 06 '21 at 15:27

1 Answers1

0

you can play with this arguments

https://graphviz.org/docs/attrs/margin/

https://graphviz.org/docs/graph/

VincentP
  • 89
  • 10