我正在写一份报告,需要使用r中的ggraph包绘制网络图。我的代码是:
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)) 我得到了一个plot:,看起来像一个蘑菇:D,有什么方法可以将网络改变成另一个形状?
发布于 2021-03-06 04:06:58
尝试设置布局,例如ggraph(net, layout = 'kk')。
发布于 2021-03-06 04:16:42
ggraph有几个内置的布局,您可以在帮助页面中看到:?create_layout。
它还从igraph中引入了几种布局算法,您可以在相应的帮助页面?layout_tbl_graph_igraph中浏览这些算法。
在这两种情况下,都可以在ggraph函数中指定它们:
ggraph(net, layout = "fr")或者使用create_layout函数:
create_layout(net, layout = "drl")https://stackoverflow.com/questions/66498707
复制相似问题