Increase the distance between igraph nodes

I have a graph that I created using igraph. I would like to decompose the nodes. The only way I've found so far is to scale the layout and make the plot command not re-scale.

png("kmeansColouredNetwork.png", width=1200,height = 1000) col=c("yellow", "saddlebrown", "brown1","chartreuse2", "chocolate1","darkorange" ,"deepskyblue1", "hotpink1","plum2") for(i in 1:9){ V(graph)$cluster[which(V(graph)$name %in% kmeans[,i])]<-col[i] } V(graph)$color=V(graph)$cluster coords <- layout.fruchterman.reingold(graph)*0.5 plot(graph, layout = coords, vertex.label=NA, rescale=FALSE, vertex.size=degree(graph)*.25,vertex.color=V(graph)$cluster) labels = paste("cluster:", 1:length(colours)) legend("left",legend=labels, col=col, pch=16, title="K means clustered subgroups") dev.off() 

If I do not rescale, the central nodes with high connectivity are combined together, and I get a graph where the patterns in the graph body cannot be distinguished: enter image description here

On the other hand, if I tell the plot command not to rescale, then I get the following: enter image description here

where the patterns are distinguishable, but half of the graph is outside the graph. This is not a question of the size of the graph, as if I were increasing the size of png, it still centers the graph from the edge of the graph.

This is not a layout issue - I tried fruchterman.reingold, layout_nicely, reingold.tilford, layout.circle, the layout is random, the same thing happens.

There apparently was a variable to set the repulsion coefficient between nodes, but this does not seem to be recommended.

How to distribute graph nodes or rescale and restart the graph?

+8
r igraph
source share
2 answers

This is NOT my answer just found on stackoverflow:
incorrectly display xlim ylim axes

Basically, you can install ylim and xlim and asp. You can specify which part of the graph to display (as usual, with xlim and ylim), and if the two axes depend on each other.

 plot(g, rescale = FALSE, ylim=c(1,4),xlim=c(-17,24), asp = 0) 
+2
source share

Option 1: Reduce Tops

 node.size= c(10,10,10) plot(net, vertex.size=node.size*0.25) 

Option 2 (if the distances between the vertices are not important to you):

 # Use the tkplot option to edit your graph in GUI tkplot (net) 

Note. tkplot displays the graphic as eps. If you want to edit it further or export it to PDF, I suggest using inkscape (I use it for all graph editing), just save the graph in pdf format in RStudio and edit it in inkscape). In the case of eps, if you are on a Windows machine, you will need to configure inkscape to open this format. A very short and simple process, which is described in detail here:

+1
source share

All Articles