rich-iannone / DiagrammeR

Graph and network visualization using tabular data in R
https://rich-iannone.github.io/DiagrammeR/
Other
1.7k stars 249 forks source link

Editing the labels on a flow chart with DiagrammeR to have bullet points and bold text #449

Open GabriellaS-K opened 2 years ago

GabriellaS-K commented 2 years ago

Thanks for an awesome package! I’m trying to make a flow chart with R. Attached is the chart I made in word (which is what I'm trying to get to). I don’t want to copy and paste it, I want to actually make it in R. I’ve been using DiagrammeR to try, and the code is below. I'm having the main trouble with the labels, how to change some parts to bold and make them a nice distance away from the nodes. I've added in the blue and pink boxes in my code, which I like. I've asked this question in stack overflow, but no luck.

Thanks!

Screenshot 2021-11-23 at 12 01 23

library(DiagrammeR)
graph <- "
digraph boxes_and_circles{

# Add node statements
# This states that all following nodes have a box shape
   node[
   shape=box,
   style=rounded,
   fontname=Helvetica,
   penwidth=2,
   fixedsize = true
   width=4
   ]

# Connect the nodes with edge statements
  edge[
  arrowhead = normal,
  arrowtail = none
  ]

# These are the main nodes at top of graph
  '@@1'->'@@2'
  [label='   Cleaning Function: 
Text to lower case
Contractions expanded
Numbers replaced
Abbreviations expanded (Qdap)
NA’s ignored
Kerns replaced
White space removed', fontname=Helvetica, fontsize=20, fontweight=bold]

  '@@2'->'@@3'
  '@@2'->'@@4'

# Make subnodes with boxes around for tidy text grouping
# graph, node, and edge definitions
  graph [
  compound = true,
  nodesep = 1,
  ranksep = 0.25,
  color = pink
  ]

# subgraph for tidy text, direct the flow
  subgraph cluster0 {
 '@@3'->'@@5' 
 [label=' -Tokenization
  -Lemetisation
    -Stop words removed', fontname=Helvetica, fontsize=20, fontweight=bold]
  }

# Make subnodes with boxes around for Dictionary grouping
# graph, node, and edge definitions
  graph [
  compound = true, 
  nodesep = 1, 
  ranksep = .25,
  color = blue
  ]

# subgraph for Dictionary direct the flow
  subgraph cluster1 { 
  node [
  fixedsize = true, 
  width = 3
  ]
  '@@4'->'@@6' [label='   Scoring function (sentimentr)
Inner Join (dplyr)',fontname=Helvetica]
  '@@6'->'@@7' [label='   Grouping
Summarise (dplyr)',fontname=Helvetica]
  '@@7'->'@@8' 
  }

 #Add a graph statement to change the properties of the graph
 graph[nodesep=1] #this modifies distance between nodes

 }

# Name the nodes
  [1]: 'Response Data'
  [2]: 'Clean Data'
  [3]: 'Tidy Text'
  [4]: 'Dictionary Creation'
  [5]: 'Visualisation'
  [6]: 'Sentiment Lexicon'
  [7]: 'Summarised Text'
  [8]: 'Visualisation and Statistics'

"
QVJD commented 2 years ago

Up

I ask myself exactly the same questions : bullet points and bold text

Please, need help