Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DiagrammeR: Adjust font size within node

I want to create a flowchart with the DiagrammeR Package in R. Within some nodes, I want to reduce the font size of some parts of the text.

Consider the following example in R:

library("DiagrammeR")

# Create a node data frame (ndf)
ndf <- create_node_df(n = 4,label = c("aaa", "bbb",
                                      "Same size\nThese letters\nshould be smaller",
                                      "ccc"))

# Create an edge data frame (edf)
edf <- create_edge_df(from = c(1, 2, 3, 3),
                  to = c(4, 3, 1, 4))

# Create a graph with the ndf and edf
graph <- create_graph(nodes_df = ndf,
                      edges_df = edf)

# Print graph
graph %>%
  render_graph()

enter image description here

The font size of the node in the middle should partly be reduced. The text "Same size" should be kept as it is. The font size of the text "These letters should be smaller" should be reduced.

Question: How could I adjust the font size for some parts of the text within a node?

like image 584
Joachim Schork Avatar asked Mar 26 '18 08:03

Joachim Schork


1 Answers

Try fixedsize = FALSE.

This adjusts the node to stretch to fit the words. It's documented here under Create_nodes but they really do not explain it very well.

The behavior to me was Fixedsize=True (in that no matter what we put in it.. the size was fixed).

So I've tried fixedsize = FALSE and it worked!

like image 77
James O'Neil Avatar answered Nov 11 '22 15:11

James O'Neil