# 1 Kime-Phases Circular distribution plots

## 1.1 Figure 6.1 (Video)

``````# r, message=FALSE, warning=FALSE, animation.hook='ffmpeg', dev='jpeg', fig.width=6, fig.height=6,  interval=0.2 (Video mode)
# r, message=FALSE, warning=FALSE, fig.width=6, fig.height=6, fig.align = 'center',animation.hook="gifski",interval=0.2 (Gif mode)
set.seed(1234)
library(circular)
x <- rvonmises(n = 200, mu = circular(pi/5), kappa = 3)
y <- rvonmises(n = 200, mu = circular(-pi/3), kappa = 5)
z <- rvonmises(n = 200, mu = circular(0), kappa = 10)
vectorX = as.vector(x)
vectorY = as.vector(y)
vectorZ = as.vector(z)
plotX = c(vectorX[1])
plotY = c(vectorY[1])
plotZ = c(vectorZ[1])
for (i in 2:200) {
plotX = c(plotX, vectorX[i])
plotY = c(plotY, vectorY[i])
plotZ = c(plotZ, vectorZ[i])
resx <- density.circular(circular(plotX), bw = 25)
resy <- density.circular(circular(plotY), bw = 25)
resz <- density.circular(circular(plotZ), bw = 25)
res <- plot(resx, points.plot = TRUE, main = "Kime-Phases Circular distribution", xlim = c(-1, 1.5), ylim = c(-1.3, 1.2), offset = 1.05, shrink = 1.3, lwd = 2)
lines(resy, points.plot = TRUE, col = 2, points.col = 2, plot.info = res, offset = 1.1, shrink = 1.3, lwd = 2)
lines(resz, points.plot = TRUE, col = 3, points.col = 3, plot.info = res, offset = 1.15, shrink = 1.3, lwd = 2)
legend("topleft",c(expression(pi/5),"0",expression(-pi/3)),fill=c("black","green","red"))
segments(0, 0, 0.9*cos(vectorX[i]), 0.9*sin(vectorX[i]), lwd=1, col= 'black')
segments(0, 0, 0.9*cos(vectorY[i]), 0.9*sin(vectorY[i]), lwd=1, col= 'red')
segments(0, 0, 0.9*cos(vectorZ[i]), 0.9*sin(vectorZ[i]), lwd=1, col= 'green')
}``````