I am using as_tbl_graph and ggraph to show the network relation data. I wish to keep the shape and location of each node, while changing the color with several conditions. Problem here is that every time I run the code, the full graph image changes at all. Is there a way to keep the shape of the graph, but only change the color? There are so many items so I can't designate each node's location.
CodePudding user response:
You can use the layout argument in ggraph to fix the graph structure, then change anything else you'd like. You can find more in the Details section of the ?ggraph help page, in the vigentte("Layouts", package = "ggraph") and in articles 
Let's say you wanted something else, so we change the layout.
p_stress <- ggraph(graph, layout = "stress")
geom_edge_link(aes(color = factor(year)))
p_stress geom_node_point()
Okay, clearly it's different from our first graph using layout = "kk". Now we can adjust the color and size of points (or whatever else we want) without changing the graph structure.
p_stress geom_node_point(color = "blue", size = 3)

