我在使用 ggplot2
制作的区域色彩地图上使用gganimate
进行动画处理时遇到了问题。
我可提供一部分数据,链接如下here, 代码如下:
library(tidyverse)
library(gganimate)
part_data <- readRDS(file = "part_data.Rds")
p <- part_data %>%
ggplot(aes(x = long, y = lat, group = group)) +
geom_polygon(aes(fill = confirmed), color = "grey70", size = 0.05) +
coord_map() +
scale_fill_distiller(trans = "log10", direction = 1, palette = "YlOrRd", na.value = "white") +
transition_time(time = date)
animate(p,
fps = 3,
duration = 5,
renderer = gifski_renderer("countyevolution.gif"),
width = 1200, height = 750, res = 100)
也许很难看到,但是如果仔细观察,您会发现县之间的边界在摆动。如果我在日期之间没有使用转换(transition_manual),则不会发生这种情况,因此它必须来自这些转换。但为什么呢?
是否可能以某种方式告诉gganimate保持边界不变,并仅为每个帧呈现填充?或者我可以通过其他方式使边界不那么明显吗?我尝试减小大小,但似乎没有任何区别。而且,边界似乎有点粗糙。