I'm using the qgraph package in R to create a network from an adjacency matrix. I want the nodes to be plotted in concentric circles, one node starting in the middle, and then plot nodes on different circles.
I received this code to create these circles and calculate the coordinates for the nodes:
nNodes=1
layoutnew <- matrix(0,nrow=nNodes,ncol=2)
tl=nNodes+1
layoutnew[,1]=sin(seq(0,2*pi, length=tl))[-tl]
layoutnew[,2]=cos(seq(0,2*pi, length=tl))[-tl]
layoutnew <- layoutnew/2
nNodes2=4
layoutnew2 <- matrix(0,nrow=nNodes2,ncol=2)
tl2=nNodes2+1
layoutnew2[,1]=sin(seq(0,2*pi, length=tl2))[-tl2]
layoutnew2[,2]=cos(seq(0,2*pi, length=tl2))[-tl2]
This code works for two circles, with 1 node in the middle and 4 on the next circle, but the third circle (with is supposed to have two more nodes) is plotted over the second circle. For this circle I used the following code:
nNodes3=2
layoutnew3 <- matrix(0,nrow=nNodes3,ncol=2)
tl3=nNodes3+1
layoutnew3[,1]=sin(seq(0,2*pi, length=tl3))[-tl3]
layoutnew3[,2]=cos(seq(0,2*pi, length=tl3))[-tl3]
Does anyone know why this is the case? Is there perhaps another way to calculate the coordinates for nodes on concentric circles?
Thanks!