I have a problem when using gganimate
to animate a choropleth map made with ggplot2
.
A selection of my data is available here and the code is:
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)
Perhaps it's difficult to see but if you look closely you'll see that the borders between the counties are wiggling. This does not happen when I use transition_manual
without transitions between the dates, so it must come from these transitions. But why?
Is it possible to somehow tell gganimate
to keep the borders the same and only render the fill
for each frame? Or can I somehow else make the border less obvious? I tried decreasing the size
, but that does not seem to make a difference. Also, the borders seem a bit jagged.