rotate a tripartite network graph

谁说胖子不能爱 提交于 2019-12-11 15:13:27

问题


I'm using a tripartite graph to visualize the overlapping club memberships among selected students in a given class, but since the output looks quite "long," I am wondering if there's a way to rotate this graph to put "Class" on top, the more numerous "Club" layer in the middle, and the "student" layer on the bottom?

Below is my code for this. It will be really appreciated if someone could share their thoughts on this.

require(igraph)
df <- read.csv2(text="Class;Club;Student
Class;Club 1;Student1
Class;Club 2;Student2
Class;Club 3;Student2
Class;Club 4;Student1
Class;Club 5;Student1
Class;Club 6;Student3
Class;Club 7;Student4
Class;Club 8;Student4
Class;Club 9;Student4
Class;Club 10;Student4")

mat <- as.matrix(df)

g <- graph_from_edgelist(rbind(mat[,1:2], mat[,2:3]), directed = F)

l <- layout_with_sugiyama(g, ceiling(match(V(g)$name, m)/nrow(m)))

plot(g, layout=-l$layout[,2:1])

来源:https://stackoverflow.com/questions/56959300/rotate-a-tripartite-network-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!