The figure sizes have been customised so that you can easily put two images side-by-side.
install.packages(c('ggplot2','gganimate','gifski'),repos="https://cran.us.r-project.org")
#> package 'ggplot2' successfully unpacked and MD5 sums checked
#> package 'gganimate' successfully unpacked and MD5 sums checked
#> package 'gifski' successfully unpacked and MD5 sums checked
#> Warning: cannot remove prior installation of package 'gifski'
#> Warning in file.copy(savedcopy, lib, recursive = TRUE): problem
#> copying D:\R-4.1.2\library\00LOCK\gifski\libs\x64\gifski.dll to D:
#> \R-4.1.2\library\gifski\libs\x64\gifski.dll: Permission denied
#> Warning: restored 'gifski'
#>
#> The downloaded binary packages are in
#> C:\Users\91991\AppData\Local\Temp\Rtmp8IyWDw\downloaded_packages
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.1.3
library(gganimate)
#> Warning: package 'gganimate' was built under R version 4.1.3
library(gifski)
#> Warning: package 'gifski' was built under R version 4.1.3data("airquality")
month<- factor(airquality$Month)
p <- ggplot(airquality,aes(Day, Wind, group = Month, color = month)) +
geom_line(lwd=1.3) +
geom_point(size=3)+
theme_bw()+
scale_color_viridis_d() +
labs(x = "Day of Month", y = "Wind") +
theme(legend.position = "top")
pp + transition_reveal(Day)
#> `geom_line()`: Each group consists of only one observation.
#> i Do you need to adjust the group aesthetic?
#> `geom_line()`: Each group consists of only one observation.
#> i Do you need to adjust the group aesthetic?