【发布时间】:2019-06-07 14:16:48
【问题描述】:
如何使用 tweenr 和 gganimate 在下面的两个条形图之间创建非常流畅的动画?
library(tweenr)
library(gganimate)
library(tidyverse)
df <- tibble(
decile = c("lowest", "second", "third", "lowest", "second", "third"),
change = c(1, 2, -0.5, -2, -3, 4),
year = c(2001L, 2001L, 2001L, 2002L, 2002L, 2002L)
)
df2001 <- filter(df, year == 2001)
df2002 <- filter(df, year == 2002)
ggplot(df2001, aes(x = decile, y = change)) +
geom_col() +
scale_y_continuous(limits = c(-5, 5)) +
theme_minimal()
ggplot(df2002, aes(x = decile, y = change)) +
geom_col() +
scale_y_continuous(limits = c(-5, 5)) +
theme_minimal()
【问题讨论】: