gganimate

Animate ggplot time series plot with a sliding window

天大地大妈咪最大 提交于 2019-12-05 10:42:10
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

Change label of gganimate frame title

≯℡__Kan透↙ 提交于 2019-12-04 23:01:02
Skimming through the options of gganimate that can be set when gg_animate() is called to render the animated sequence, it seems that there is no option to change the frame title so to make it clearer to the observer of what is the parameter that the frame is based on. In other words, suppose that frame = year in a layer: how do I make the frame's title be year: #### where #### is the year of the current frame? Am I missing something or is it a limitation of the gganimate library? How would you achieve the same result by a workaround? Thanks for your advice. Update for new gganimate API

GGanimate: geom_text with numeric values animates at decimal numbers instead of integers

一笑奈何 提交于 2019-12-04 16:42:30
Data <- data.frame(Time = c(1, 1, 1, 2, 2, 2, 3, 3, 3), Group = c("A", "B", "C", "A", "B", "C", "A", "B", "C"), Value = c(20, 10, 15, 20, 20, 20, 30, 25, 35)) I have three Groups with Values at three different points in Time . library(ggplot2) library(gganimate) p <- ggplot(Data, aes(Group, Value)) + geom_col(position = "identity") + geom_text(aes(label = Value), vjust = -1) + coord_cartesian(ylim = c(0, 40)) + transition_time(Time) p The above code produces the animation for the transformation of the bars quite well, but the change in the geom_text leaves much to be desired, as the geom_text

Any way to pause at specific frames/time points with transition_reveal in gganimate?

一世执手 提交于 2019-12-04 08:16:07
问题 Utilising this example from the package's wiki on Github: airq <- airquality airq$Month <- format(ISOdate(2004,1:12,1),"%B")[airq$Month] ggplot(airq, aes(Day, Temp, group = Month)) + geom_line() + geom_segment(aes(xend = 31, yend = Temp), linetype = 2, colour = 'grey') + geom_point(size = 2) + geom_text(aes(x = 31.1, label = Month), hjust = 0) + transition_reveal(Month, Day) + coord_cartesian(clip = 'off') + labs(title = 'Temperature in New York', y = 'Temperature (°F)') + theme_minimal() +

Prevent title space changing when animating with descender letters

被刻印的时光 ゝ 提交于 2019-12-04 03:11:31
问题 I am trying to animate some monthly data using gganimate . The plots are working great, except that the presence of descenders (letters that go below the baseline, i.e. g, j, p, q, and y) changes the amount of space that the title takes up. This, in turn, moves the baseline of the title just a bit, which detracts from the animation. That is, the title noticably "jumps" up a bit when there is a descender in the title. An example: myDF <- data.frame( Date = seq(as.Date("2015-01-15") , as.Date(

Prevent title space changing when animating with descender letters

∥☆過路亽.° 提交于 2019-12-01 16:45:10
I am trying to animate some monthly data using gganimate . The plots are working great, except that the presence of descenders (letters that go below the baseline, i.e. g, j, p, q, and y) changes the amount of space that the title takes up. This, in turn, moves the baseline of the title just a bit, which detracts from the animation. That is, the title noticably "jumps" up a bit when there is a descender in the title. An example: myDF <- data.frame( Date = seq(as.Date("2015-01-15") , as.Date("2015-12-15") , "1 month") , x = 1:12 , y = 1:12 ) myDF$frame <- factor(format(myDF$Date, "%Y-%b") ,

gganimate issue with geom_bar?

时间秒杀一切 提交于 2019-12-01 00:26:04
问题 I've been looking with envy and admiration at the various ggplot animations appearing on twitter since David Robinson released his gganimate package and thought I'd have a play myself. I am having an issue with gganimate when using geom_bar. Hopefully the following example demonstrates the problem. First generate some data for a reproducible example: df <- data.frame(x = c(1, 2, 1, 2), y = c(1, 2, 3, 4), z = c("A", "A", "B", "B")) To demonstrate what I'm trying to do I thought it would be

gganimate animate multiple paths based on time

前提是你 提交于 2019-12-01 00:01:30
I have parsed some data on grenade throws from the videogame Counter Strike. The sample data beloew reveals that I have positions on where the grenade is thrown from and where the grenade detonates and when the grenade is thrown. df <- data.frame(pos_x = c(443.6699994744587,459.4566921116250, 443.5131582404877, 565.8823313012402, 725.3048665125078, 437.3428992800084, 475.7286794460795, 591.4138769182258), pos_y = c(595.8564633895517, 469.8560006170301, 558.8543552036199, 390.5840189222542, 674.7983854380914, 688.0909476552858, 468.4987145207733, 264.6016042780749), plot_group = c(1, 1, 2, 2, 3

gganimate animate multiple paths based on time

让人想犯罪 __ 提交于 2019-11-29 23:45:06
问题 I have parsed some data on grenade throws from the videogame Counter Strike. The sample data beloew reveals that I have positions on where the grenade is thrown from and where the grenade detonates and when the grenade is thrown. df <- data.frame(pos_x = c(443.6699994744587,459.4566921116250, 443.5131582404877, 565.8823313012402, 725.3048665125078, 437.3428992800084, 475.7286794460795, 591.4138769182258), pos_y = c(595.8564633895517, 469.8560006170301, 558.8543552036199, 390.5840189222542,

Display different time elements at different speeds in gganimate

好久不见. 提交于 2019-11-28 14:25:16
Using the code from this answer, How to make dots in gganimate appear and not transition , as a MWE, say we have this gganimate: library(ggplot2) library(gganimate) a <- ggplot(airquality, aes(Day, Temp, group = interaction(Month, Day))) + geom_point(color = 'red', size = 1) + transition_time(Month) + shadow_mark(colour = 'black', size = 0.75) + enter_fade() animate(a, nframes = 100) or animate(a, fps=5) Is it possible to control the speed of each Month (time element)? For example, display Month 5 very quickly, ..., Month 9 very slowly. This is my rudimentary try by making a helper column