r - increasing the distance between igraph nodes -
i have graph have produced using igraph. i'd spread out nodes. way have found far scale layout , force plot command not rescale.
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 don't rescale, central highly connected nodes clump , graph this, patterns in body of graph impossible discern:
on other hand, if tell plot command not rescale, :
where patterns discernible, half graph off plot. it's not matter of plot size if increase dimensions of png, still centres graph off edge of plot.
it's not matter of layout - i've tried fruchterman.reingold, layout_nicely, reingold.tilford, layout.circle, layout random, same thing happens.
there apparently used variable set repulsion factor between nodes, appears deprecated.
how 1 spread nodes of graph out or rescale , recenter plot?
it not answer, found on stackoverflow:
igraph axes xlim ylim plot incorrectly
basically, can set ylim , xlim , asp. can set part of graph display (as usual xlim , ylim) , if 2 axis dependent on each other.
plot(g, rescale = false, ylim=c(1,4),xlim=c(-17,24), asp = 0)
Comments
Post a Comment