Reputation: 109
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?
Upvotes: 1
Views: 1012
Reputation: 372
ggraph
has several built in layouts which you can see in this help page: ?create_layout
.
It also pulls in several layout algorithms from igraph
which you can browse in the appropriate help page: ?layout_tbl_graph_igraph
.
In either case, you can specify them in either the ggraph
function:
ggraph(net, layout = "fr")
Or use the create_layout
function:
create_layout(net, layout = "drl")
Upvotes: 2