Search code examples
rggplot2network-programmingggraph

How to change the layout of a ggraph network plot?


I'm working on a report needs to plot a network using the ggraph package in r. My code is:

net <- graph_from_data_frame(d=edges,vertices=nodes,directed = F)
ggraph(net) + 
geom_edge_link(aes(alpha=color)) + 
geom_node_point(aes(shape=as.factor(gender),alpha=location)) 

and I get a plot:, looks like a mushroom :D, is there any way can change the network to another shape?


Solution

  • Try setting the layout, e.g. ggraph(net, layout = 'kk').