Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Igraph circle layout: Tweak appeareance of reflexive edges' label

Tags:

plot

igraph

I have this figure plotted with the layout.circle algorithm of the `igraph package.

enter image description here

Some labels of the self-loop ties on the left are not clearly visible since are placed behind inter-nodes edges. Is there any tweak I could apply to improve the readability of the plot without changing the distance of the labels? (I guess that plotting the loops on the radial vectors of the circle is out of the question without recoding the whole thing...)

This is the code

par(mar=c(0,0,0,0))
plot(g, 
     layout=layout.circle,
     vertex.label.family="Palatino",
     edge.label.family="Palatino",
     edge.label.cex=0.7,
     vertex.size=log(V(g)$community_size)+7,
     vertex.label=V(g)$community_size,
     edge.width=log(E(g)$weight),
     edge.label=E(g)$weight)
like image 671
CptNemo Avatar asked Nov 25 '13 01:11

CptNemo


1 Answers

Plot the same graph twice, first with the edges, but without the labels, and then without the edges and the vertices and with the labels. Some useful bits:

  • For the second plot, use add=TRUE.
  • To omit the edges, set their width to zero.
  • To omit the vertices, set their shape to none.
  • To omit the edge labels, set them to NA, or the empty string.

Edit

To fix the layout, pre-calculate it and store it in a variable:

  lay <- layout.circle(g)
  plot(g, layout=lay, ...)
  plot(g, add=TRUE, layout=lay, ...)
like image 178
Gabor Csardi Avatar answered Sep 25 '22 19:09

Gabor Csardi