Skip to content
Prev 367139 / 398506 Next

Circular plot

Hi Swaraj,
As David pointed out, you can get the arcs without too much trouble:

library(plotrix)
mdf<-data.frame(score=c(-1,7,4,-7),start=c(0,0,600,800),
 finish=c(100,200,800,1250))
par(mar=c(4,4,1,1))
plot(0,type="n",xlim=c(-20,20),ylim=c(-20,20),xlab="",ylab="",
 xaxt="n",yaxt="n")
axis(1,at=c(-20,-10,0,10,20),labels=c(10,0,-10,0,10))
axis(2,at=c(-20,-10,0,10,20),labels=c(10,0,-10,0,10))
draw.circle(0,0,10,lty=2,border="black")
mlength<-1500
for(i in 1:dim(mdf)[1]) {
draw.arc(0,0,10+mdf$score[i],
 angle1=2*pi*mdf$start[i]/mlength,
 angle2=2*pi*mdf$finish[i]/mlength,
 lwd=3,col=ifelse(mdf$score[i]<0,"red","blue"))
}

However, you may want a circular grid as well as clockwise angles:

par(mar=c(1,1,1,1))
plot(0,type="n",xlim=c(-6,6),ylim=c(-6,6),
 xlab="",ylab="",axes=FALSE)
radial.grid(seq(0,1250,by=250),radial.lim=c(0,10),
 label.pos=seq(0,12.5/15,by=2.5/15)*2*pi,
 grid.pos=seq(0,12.5/15,by=2.5/15)*2*pi,
 start=pi/2,clockwise=TRUE)
for(i in 1:dim(mdf)[1]) {
 draw.arc(0,0,(10+mdf$score[i])/4.5,
  deg1=450-360*mdf$start[i]/mlength,
  deg2=450-360*mdf$finish[i]/mlength,
  lwd=3,col=ifelse(mdf$score[i]<0,"red","blue"))
}

Both of these examples are pretty messy, but could be improved if you
have a lot of work like this.

Jim
On Tue, Feb 14, 2017 at 8:58 AM, swaraj basu <projectbasu at gmail.com> wrote: