Directly Adding Titles and Labels to Visnetwork

I have the following network graph:


data = data.frame(tibble(d = paste(1:n)))

relations = data.frame(tibble(
  from = sample(data$d),
  to = lead(from, default=from[1]),

data$name = c("new york", "chicago", "los angeles", "orlando", "houston", "seattle", "washington", "baltimore", "atlanta", "las vegas", "oakland", "phoenix", "kansas", "miami", "newark" )

graph = graph_from_data_frame(relations, directed=T, vertices = data) 

V(graph)$color <- ifelse(data$d == relations$from[1], "red", "orange")

plot(graph,, edge.arrow.size = 0.2, main = "my_graph")

I was able to convert this graph into a "visnetwork" graph:



enter image description here

Now, I am trying to put a title on this graph:

visIgraph(graph, main = "my title")

Although this doesn't work:

Error in layout_with_fr(graph, dim = dim, ...) : 
  unused argument (main = "my title")

I found this link Legend that shows how you can add titles to a "visnetwork" graph :

nodes <- data.frame(id = 1:3, group = c("B", "A", "B"))
edges <- data.frame(from = c(1,2), to = c(2,3))

# default, on group
visNetwork(nodes, edges, 
           main = "A really simple example", 
           submain = list(text = "Custom subtitle",
                          style = "font-family:Comic Sans MS;color:#ff0000;font-size:15px;text-align:center;"), 
           footer = "Fig.1 minimal example",
           width = "100%")

This seems to be pretty straightforward, but it requires you to use the "visNetwork()" function instead of the "visIgraph()" function.

  • Is it possible to directly add titles using the "visIgraph()" function?

Thank you!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.