Animate ggplot time series plot with a sliding window
I'm looking for ways to animate a long time series plot without losing resolution. I would like the view to "pan" across the data, showing a sliding subset of it from the beginning to the end. Suppose I have the following: library(ggplot2) library(dplyr) library(gganimate) df <- as.data.frame(cumsum(rnorm(1:10000))) %>% rename(y = 1) df <- mutate(df, seq = seq(1, 10000, by = 1)) ggplot(df, aes(x = seq, y = y)) + geom_line() I'd like to create an animation that shows more detail by just focusing on one section of the data at a time, and sliding along from the beginning to the end. Imagine