Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created March 25, 2024 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abikoushi/9b9636fc603b8007eb230777318bdf09 to your computer and use it in GitHub Desktop.
Save abikoushi/9b9636fc603b8007eb230777318bdf09 to your computer and use it in GitHub Desktop.
Lissajous Curve
library(gganimate)
library(dplyr)
th <- seq(-pi,pi,by=0.01)
a <- seq(1,6, by=0.1)
df <- data.frame(x=c(cos(outer(th,a))),
y=rep(sin(th), length(a)),
a=rep(a, each=length(th)))
ggplot(df, aes(x=x, y=y, group=a, colour=a))+
geom_path()+
facet_wrap(~a)+
scale_color_continuous(type = "viridis")+
theme_classic()+ coord_fixed()
####
#bob
th <- seq(-pi,pi,by=0.001)
a <- 3
df <- data.frame(x=cos(a*th),
y=sin(th),
th=th)
ggplot(df, aes(x=x, y=y, group=1))+
geom_path(linewidth=2)+
theme_classic(18)+ coord_fixed()+
transition_reveal(th)
anim_save("bob.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment