Tuesday, May 31, 2016

A nice pattern... (discovered while working on a new plot method)

This has nothing to do with phylogenetics (or at least not yet), but here is the outcome when I space points evenly on a circle, draw lines between all of them, and then color the lines using semi-transparent colors of the rainbow:

par(bg="black")
plot.new()
par(mar=rep(0.1,4))
plot.window(xlim=c(-1,1),ylim=c(-1,1),asp=1)
nstates<-40
step<-360/nstates
angles<-seq(0,360-step,by=step)
v.x<-cos(angles/180*pi)
v.y<-sin(angles/180*pi)
colors<-rainbow(n=nstates*nstates,start=0.05,end=0.95,
    alpha=0.3)
for(i in 1:nstates) for(j in 1:nstates) 
    segments(v.x[i],v.y[i],v.x[j],v.y[j],
        colors[i+(i-1)*nstates+j])

plot of chunk unnamed-chunk-1

The first part of this is for a plotting method I decided I'd like to add for discrete character models fit using fitMk. The second part is for fun.

1 comment:

  1. This would probably look cooler if I wasn't colorblind.

    ReplyDelete

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.