使用gganimate

时间:2018-11-08 13:26:47

标签: r ggplot2 sf gganimate

我正在为一张地图制作动画,其中包含非洲由艾滋病毒/艾滋病造成的死亡百分比。多年来,动画效果很好,但另一些年来,这些国家却在跳来跳去。可以找到数据here。我的代码如下所示

library(sf)
library(rworldmap)
library(transformr)
library(gganimate)
library(tidyverse)

mortality <– read_csv("path_to_file")

africa_map <- getMap(resolution = "low") %>% st_as_sf() %>% 
 filter(continent == "Africa")

mortality %>% filter(region == "Africa", disease == "HIV/AIDS") %>% 
 mutate(year = as.integer(year(year))) %>% drop_na() %>% 
 left_join(africa_map, by = c("country_code" = "SOV_A3")) %>% 
 ggplot() + geom_sf(aes(fill = percent)) +
 transition_time(year) +
 labs(title = "Year: {frame_time}")

有什么解决方法吗?

0 个答案:

没有答案
相关问题