The butterfly curve

October 7, 2015
By

(This article was originally published at » R, and syndicated at StatsBlogs.)

I came across the butterfly curve, which was discovered by Temple Fay. The butterfly curve is produced by a parametric equation where:
x = sin(t) * (e^cos(t)-2cos(λt)-sin(t/12)^5) and
y = cos(t) * (e^cos(t)-2cos(λt)-sin(t/12)^5).
Where t stands for time and λ for a user input variable.

I used ggplot to create a plot of the butterfly curve with a background of the same color pattern. After sourcing the function, the user can vary the number of background points, as well as the butterfly curves.

butterfly

library(ggplot2)
source("https://raw.githubusercontent.com/danielmarcelino/SciencesPo/master/R/butterfly.R")

> p1 = butterfly(10, 100, title="10 x 100")

Date of Analysis: Wed Oct 07 2015
Computation time: 0.009749889
-----------------------------------
> p2 = butterfly(10, 200, title="10 x 200")

Date of Analysis: Wed Oct 07 2015
Computation time: 0.01240611
-----------------------------------
> p3 = butterfly(10, 500, title="100 x 500")

Date of Analysis: Wed Oct 07 2015
Computation time: 0.02488399
-----------------------------------
> p4 = butterfly(100, 1000, title="100 x 1000")

Date of Analysis: Wed Oct 07 2015
Computation time: 0.01444697
-----------------------------------
 multiplot(p1,p2,p3,p4, ncols = 2)



Please comment on the article here: » R

Tags: , ,


Subscribe

Email:

  Subscribe