By aschinchon
Se le nota en la voz, por dentro es de colores (Si te vas, Extremoduro)
This is a gif generated with 25 plots of the Fermat’s spiral, a parabolic curve generated through the next expression:
where is the radius,
is the polar angle and
is simply a compress constant.
Fermat showed this nice spiral in 1636 in a manuscript called Ad locos planos et solidos Isagoge (I love the title). Instead using paths, I use a polygon geometry to obtain bullseye style plots:
Playing with this spiral is quite addictive. Try to change colors, rotate, change geometry … You can easily discover cool images like this without any effort:
Enjoy!
library(ggplot2) library(magrittr) setwd("YOUR-WORKING-DIRECTORY-HERE") opt=theme(legend.position="none", panel.background = element_rect(fill="white"), panel.grid=element_blank(), axis.ticks=element_blank(), axis.title=element_blank(), axis.text=element_blank()) for (n in 1:25){ t=seq(from=0, to=n*pi, length.out=500*n) data.frame(x= t^(1/2)*cos(t), y= t^(1/2)*sin(t)) %>% rbind(-.) -> df p=ggplot(df, aes(x, y))+geom_polygon()+ scale_x_continuous(expand=c(0,0), limits=c(-9, 9))+ scale_y_continuous(expand=c(0,0), limits=c(-9, 9))+opt ggsave(filename=paste0("Fermat",sprintf("%03d", n),".jpg"), plot=p, width=3, height=3)}
Related
To leave a comment for the author, please follow the link and comment on their blog: Ripples.
R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more…
If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook…
Source:: r-bloggers.com