Sunday 27 March 2016

Happy Easter! with an R egg

This morning to entertain my daughter I thought I'd create a colourful egg using the R programming language. I was rather surprised to find that my google searches for any existing code did not reveal anything. Anyway, after a bit of playing around, herewith a token celebration of Easter.

R-easter egg
and the code that made it:

library(plotrix)
plot(c(1.5,8.5), c(0,10), type="n", main="Easter Egg", xlab="bunny", ylab="chocolate")

draw.ellipse(c(5), c(5), c(2),c(5.5),col=c(2))
draw.ellipse(c(5), c(4.9), c(2),c(5),col=c(4))
draw.ellipse(c(5), c(4.8), c(2),c(4.5),col=c(1))
draw.ellipse(c(5), c(4.5), c(2),c(4.5),col=c(1))
draw.ellipse(c(5), c(4.6), c(2),c(4),col=c(3))
draw.ellipse(c(5), c(4.4), c(1.9),c(3.5),col=c(5))
draw.ellipse(c(5), c(4.2), c(1.8),c(3),col=c(6))
draw.ellipse(c(5), c(4), c(1.7),c(2.5),col=c(7))
draw.ellipse(c(5), c(3.8), c(1.6),c(2),col=c(8))
draw.ellipse(c(5), c(3.5), c(1.5),c(1.5),col=c(9))
draw.ellipse(c(5), c(3.5), c(1.2),c(1.2),col=c(10))
draw.ellipse(c(5), c(3.3), c(.5),c(.5),col=c(6))

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...