Replicating UCINET Graphical output

I am new to the forum and I hope my question is posted according to the rules.
I would like to replicate the graphical output obtained by Ucinet as in this figure:

which is on page 14 of the Calderoni’s paper available at

Specifically I would like set each node coordinates as parameters

Any suggestion is welcome

PS I am grateful to Francesco Calderoni for allowing me to use his picture.

You haven’t specified whether you are using igraph from R, Python or Mathematica, but one thing is common for at least R and Python (@szhorvat can comment on the Mathematica interface): the layout= argument of the plot() function accepts matrices with exact coordinates. So, you only need to create a matrix with N rows and 2 columns (use lists-of-lists or lists-of-tuples in Python), and pass it to plot() like this:

plot(g, layout=my_layout)
1 Like

Thank you for the reply, actually I am using it from R.

I will try your suggestion.

Hi everyone,
Thanks @tamas for your reply. As you state, the ‘Iayout=’ argument accepts matrices with the coordinates. I am collaborating with @umerlone in this work and I wanted to share with the community how we replicated the output in ‘igraph’ for R. I’d really appreciate suggestions!

set.seed(77) #for reproducible example
g <-, 1.3, directed = FALSE) #generate a scale-free graph

#generate some node attributes
V(g)$attr1 <- sample(letters[1:3], 30, replace = TRUE)  
V(g)$attr2 <- sample(c('high','medium','low'), 30, replace = TRUE)

We now have a graph with 50 nodes with two different categorical attributes having three levels each. We want to create a plot where the nodes are clustered depending on their attributes. In particular, attr1 will define the longitude coordinates of the nodes, and attr2 will define their latitude. Let’s create the coordinate.

#generate coordinates for the x-axis
coordx = ifelse(V(g)$attr1 ==  'a', runif(length(V(g)$attr1), min= -2, max = -1),
                ifelse(V(g)$attr1 =='b', runif(length(V(g)$attr1), min= 0, max = 1),
                 runif(length(V(g)$attr1), min= 2, max = 3)))
#generate coordinates for the y-axis                       
coordy = ifelse(V(g)$attr2 ==  'low', runif(length(V(g)$attr2), min= -1, max = 0),
                ifelse(V(g)$attr2 =='medium', runif(length(V(g)$attr2), min= 1, max = 2),  
                       runif(length(V(g)$attr2), min= 3, max = 4)))

As you can see, we let the system generate some random coordinates from a given interval both for the x and y-axis. Each level of the attributes has its own interval. I know a little about coordinates for graphical outputs in R, but this solution worked pretty well for us.

#some color for the plot
V(g)[V(g)$attr1 == 'a']$color <- "#008080"   
V(g)[V(g)$attr1 == 'b']$color <- "#808080"   
V(g)[V(g)$attr1 == 'c']$color <- "#DAA520"  

# create the 2 x 2 matrix with N= vcount(g)

m <- matrix(0, vcount(g), 2)
m[,1] = coordx
m[,2] = coordy

#and plot the graph using the matrix m as the layout argument

plot(g, layout = m, vertex.size = 5, vertex.label = NA)

# simple axis

axis(1, , at = c(-1, 0, 1), labels = c('a','b','c'))
axis(2, at = c(-0.75, 0, 0.75), labels = c('low', 'medium','high'))

Actually, for a better graphical representation, we used the ‘popgraph’ library with ‘ggplot2’, but this example is a good start. Ideally, it’s possible to add attributes.

This is my first post, I hope to have followed the guidelines.


1 Like