2

In R, How can I have a multi-line title in visNetwork? \n Doesn't seem a solution:

require(visNetwork, quietly = TRUE) 
# minimal example 
nodes <- data.frame(id = 1:3) 
edges <- data.frame(from = c(1,2), to = c(1,3)) 
visNetwork(nodes, edges, main ="multi \n line \n title")

enter image description here

Sadegh
  • 865
  • 1
  • 23
  • 47

1 Answers1

5

Being interactive visNetwork use HTML instead of standard plotting.
Use HTML's new line tag <br>:

visNetwork(nodes, edges, main ="multi<br>line<br>title")

To align on the left, or to apply any other style use a named list as argument for main:

visNetwork(nodes, edges, main = list(
                                 text = "multi<br>line \n title", 
                                 style = "font-family:Comic Sans MS;color:#ff0000;
                                          font-size:15px;text-align:left;"))
GGamba
  • 13,140
  • 3
  • 38
  • 47