我正在尝试使用R
和ggplot2
为gganimate
中的一些图制作动画。
我阅读了一些教程,并成功制作了gapminder
数据的动画。
但是,当我尝试对数据集进行动画处理时遇到了问题。首先,我创建了plot
并尝试对其进行动画处理:
animate_data_1 <- ggplot(data_1,
aes(x = Month, y = rain, colour = factor(Year))) +
geom_line(stat = "identity") +
labs(x = "Month", y = "Rain") +
geom_point(show.legend = FALSE, alpha = 0.7) +
scale_color_viridis_d()
animate_data_1
animate_data_1 + transition_time(Year) + labs(title = "Year: {frame_time}")
上面的代码创建了动画情节,但是它一次显示一年,然后更改为另一年。但是,我希望全年都会一次更改该值(从头到尾不断增加)。像这个例子data gradually appear
因此,我进行了更改:
animate_data_1 +
geom_point(aes(group = seq_along(Month))) +
transition_reveal(Year) +
labs(title = "Year: {frame_time}")
现在它显示此错误:
Error: Provided file does not exist In addition: There were 50 or more warnings (use warnings() to see the first 50)
出什么问题了?怎么解决呢?
我的数据:
tem Month Year rain
1 16.9760 1 1901 18.53560
2 19.9026 2 1901 16.25480
3 24.3158 3 1901 70.79810
4 28.1834 4 1901 66.16160
5 27.8892 5 1901 267.21500
6 28.8925 6 1901 341.04200
7 28.3327 7 1901 540.90700
8 27.9243 8 1901 493.21000
9 27.6057 9 1901 291.54900
10 27.0887 10 1901 199.17100
11 22.1671 11 1901 126.28500
12 18.5574 12 1901 1.69035
13 18.5455 1 1902 1.29152
14 20.1252 2 1902 0.14722
15 25.5508 3 1902 62.76860
16 26.5562 4 1902 229.58900
17 27.3165 5 1902 302.19700
18 28.2660 6 1902 528.77500
19 27.6247 7 1902 415.25700
20 28.1001 8 1902 435.16600
21 27.7271 9 1902 282.87200
22 26.0153 10 1902 76.65180
答案 0 :(得分:0)
尝试一下,但是时间框架还没到。但是,这段代码并未给出逐渐增加的情节,而是一年又一年地给出
animate_data_1 +
geom_point(aes(group = seq_along(Year)))+
transition_reveal(Year)
答案 1 :(得分:0)