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])