devtools::install_github('thomasp85/gganimate')
library(gganimate)
library(ggplot)
set.seed(123)
rain.data <- data.frame(ID = 1:50, year = rep(1981, times = 365*50),
doy = rep(1:365, times = 50), rain = rnorm(365*50))
对于一天,如果我想绘制所有ID
上的降雨值
rain.data %>% dplyr::filter(doy == 1) %>% ggplot(., aes(rain)) + geom_histogram()
如果要制作一年中每一天的下雨动画,我可以这样做:
ggplot(rain.data, aes(rain)) + geom_histogram(show.legend = FALSE) +
labs(title = 'Doy: {frame_time}', x = 'Rain', y = '# Count') +
transition_time(doy)
这看起来不正确,绝对不是直方图。我在做什么错了?