Created
March 3, 2023 16:18
-
-
Save abikoushi/a1798f22df11cb389a5a47ffc7380920 to your computer and use it in GitHub Desktop.
Heart equation with gganimate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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