Reputation: 71
The following network has around 13K nodes with 5 big communities. However, two of the communities are trapped under this layout. I generated this plot using this code:
library(qgraph)
col=c("#5150a7","#c3200f","#ed9718","#017acb","#FFC0CB","#9c9bd5")
e <- as.data.frame(get.edgelist(g))
lay <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(g))
plot(g,layout=lay,vertex.color=col[V(g)$community],vertex.label =NA, vertex.size= 2)
Changing area parameter also didn't help. How can I correct the plot to see all the nodes without reducing vertex.size?
Upvotes: 1
Views: 513
Reputation: 37661
Based on the data provided (link in comments), this answer has been completely reworked. Also, it appears that you actually had 6 communities, not 5.
I will use the data that you provided and start with your code but
with some minor variations. You use the qgraph
package and I will
just stick to igraph
. Also you create your layout with
qgraph.layout.fruchtermanreingold
. I will use layout_with_lgl
from igraph. Otherwise, my starting place is your code.
library(igraph)
load("temp/networkplot_so.RData")
col=c("#5150a7","#c3200f","#ed9718","#017acb","#FFC0CB","#9c9bd5")
set.seed(1234)
lay = layout_with_lgl(g)
plot(g,layout=lay,vertex.color=col[V(g)$community],
vertex.label =NA, vertex.size= 2)
A way to get a more useful presentation is to start from the existing layout and move things around. We want to be able to see the different communities, but they are all overlapping each other in the center. To fix that we move each community away from the center in a different direction (except the biggest cluster that we leave in the middle). First though, I want to get an idea of how much to move the clusters.
summary(lay)
V1 V2
Min. :-2871 Min. :-6293
1st Qu.: 1710 1st Qu.: 2344
Median : 2411 Median : 3541
Mean : 3108 Mean : 3285
3rd Qu.: 4300 3rd Qu.: 4397
Max. :15712 Max. : 8500
This shows how much the points vary around the mean. From this, I guessed that we should move the clusters about 7000 units. After trying 7000, I adjusted the numbers to make it a little nicer. After my adjustments, here is where I ended up.
LO2 = lay
LO2[V(g)$community == 1,1] = LO2[V(g)$community == 1,1] + 10000
LO2[V(g)$community == 2,2] = LO2[V(g)$community == 2,2] - 7000
LO2[V(g)$community == 3,1] = LO2[V(g)$community == 3,1] - 10000
LO2[V(g)$community == 4,2] = LO2[V(g)$community == 4,2] + 7000
LO2[V(g)$community == 5,1] = LO2[V(g)$community == 5,1] + 6000
LO2[V(g)$community == 5,2] = LO2[V(g)$community == 5,2] + 5000
plot(g,layout=LO2,vertex.color=col[V(g)$community],
vertex.label =NA, vertex.size= 2)
legend("bottomleft", legend=1:6, pch=20, cex=0.5, col=col)
You can see each of the communities. It looks like group 6 really is central. The other smaller groups connect to 6, but not so much to each other. You may want to adjust the layout differently to emphasize other relationships, but this should be a good start.
Upvotes: 1