Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created March 3, 2023 16:18
Show Gist options
  • Save abikoushi/a1798f22df11cb389a5a47ffc7380920 to your computer and use it in GitHub Desktop.
Save abikoushi/a1798f22df11cb389a5a47ffc7380920 to your computer and use it in GitHub Desktop.
Heart equation with gganimate
library(gganimate)
library(dplyr)
th <- seq(-1,1,by=0.001)
ran <- c(-0.85,-0.2)
df <- data.frame(x = sin(th)*cos(th)*log(abs(th)),
y = (abs(th)^0.3)*sqrt(abs(cos(th))),
theta=th) %>%
mutate(f = ran[1]<theta & theta<ran[2]) %>%
mutate(time_dummy = row_number())
ggplot(df, aes(x=x, y=y, colour=f, group=1))+
geom_path(linewidth=2)+
theme_classic()+
transition_reveal(time_dummy)
anim_save("tsu.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment