# plotting a rainbow n<-16 colors<-rev(rainbow(n=16)) # To form a half-circle ('rainbow-shaped') I use cosine and sine functions # each time the radius gets increased a little bit by the scaling # factor, and every time a different color is picked from the # color-values (RBG-code: FF0000 would be pure red, 00FF00, green, 00000FF blue # these are hexadecimal numbers). rainbow # r<-seq(-pi/2,pi/2,0.1) y<-cos(r) x<-sin(r) scale<-1 incr<-0.2 linewidth<-2 plot(c(-2,2),c(-2,2),typ='n',axes=FALSE,xlab='',ylab='',main="A rainbow color demo") for (i in 1:n){ scale<-scale+incr/n print(scale) lines((scale*x),(scale*y),col=colors[i],typ='l',lwd=linewidth) }