Happy Valentines day by Nerds

February 14, 2019

(This article was first published on Rbloggers – The Analytics Lab, and kindly contributed to R-bloggers)

Real nerds on Valentines day graph hearts instead of drawing them. My drawing skills are not what I like them to be, my R skills are though! Therefore, let’s draw a heart in R instead on paper!

heart curve

dat<- data.frame(t=seq(0, 2*pi, by=0.01) )
xhrt<- function(t) 16*sin(t)^3
yhrt<- function(t) 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)

with(dat, plot(x,y, type="l", axes=FALSE, frame.plot=FALSE, labels = FALSE, xlab = '', ylab = ''))
with(dat, polygon(x,y, col="#FF7575"))

Inspired by: http://mathworld.wolfram.com/HeartCurve.html


To leave a comment for the author, please follow the link and comment on their blog: Rbloggers – The Analytics Lab.

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...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)