Reputation: 63
I am making a large network visualization with 748 vertices and 2228 edges.
It looks similar to the plot produced in this:
library(networkDynamic)
library(network)
library(sna)
library(intergraph)
library(igraph)
# Set up data set.seed(123)
g <- barabasi.game(750)
# Plot data
plot.igraph(g,
margin = c(0, 0, 0, 0),
rescale = TRUE,
edge.arrow.size= .2,
vertex.size = 4,
vertex.label=NA)
Is there any way to avoid vertices from clustering together?
I tried to set the margin so that the plotting region can be maximized, but it doesn't work.
Upvotes: 0
Views: 390
Reputation: 4586
I think best to use qgraph
to obtain a Fruchterman-Reingold layout. Before igraph
too could do it, but in the recent version the algorithm has been rewritten and it lost this feature. It was not my idea to use qgraph
I have seen somewhere but don't remember where, sorry for missing credits.
library(igraph)
library(qgraph)
make_fr_layout <- function(g){
# layout with qgraph
# g is an igraph object
el <- get.edgelist(g, names = FALSE)
lo <- qgraph.layout.fruchtermanreingold(el, vcount = vcount(g),
area = vcount(g)^2.3,
repulse.rad = vcount(g)^2.1,
niter = 3000)
lo
}
set.seed(123)
g <- barabasi.game(750)
lo <- make_fr_layout(g)
cairo_pdf(filename = 'nice-layout.pdf')
plot.igraph(g,
layout = lo,
margin = c(0, 0, 0, 0),
rescale = TRUE,
edge.arrow.size = .2,
vertex.size = 4,
vertex.label = NA)
dev.off()
Upvotes: 1