2

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

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}")

知道如何解决这个问题吗?

4

0 回答 0