-
-
Save thomasp85/9362bbfae956f2690794abeb2c11cdcc to your computer and use it in GitHub Desktop.
library(ggplot2) | |
library(gganimate) | |
library(sf) | |
earth <- sf::st_as_sf(rnaturalearth::countries110) | |
views <- data.frame(rbind( | |
st_bbox(earth[earth$name == 'Denmark',]), | |
st_bbox(earth[earth$name == 'Australia',]) | |
)) | |
p <- ggplot() + | |
geom_sf(data = earth, fill = 'white') + | |
geom_sf(data = earth[earth$name %in% c('Denmark', 'Australia'),], fill = 'forestgreen') + | |
theme(panel.background = element_rect('lightblue')) + | |
view_zoom_manual(1, 1, xmin = views$xmin, xmax = views$xmax, ymin = views$ymin, ymax = views$ymax, wrap = TRUE) | |
animate(p, 100, 10) |
thomasp85
commented
Jun 11, 2018
Thank you for the code!
When I try to reproduce the animation with the same code, however, I always encounter the following error:
Error in params$nframes : $ operator is invalid for atomic vectors
And the problem seems to be in
view_zoom_manual(1, 1, xmin = views$xmin, xmax = views$xmax, ymin = views$ymin, ymax = views$ymax, wrap = TRUE)
Do you have any idea why this happens? Thanks.
Thank you for the code!
When I try to reproduce the animation with the same code, however, I always encounter the following error:
Error in params$nframes : $ operator is invalid for atomic vectors
And the problem seems to be in
view_zoom_manual(1, 1, xmin = views$xmin, xmax = views$xmax, ymin = views$ymin, ymax = views$ymax, wrap = TRUE)
Do you have any idea why this happens? Thanks.
I too have this issue. Anything?
I had no problems running the code. I'd just add the following line at the end to save the plot anim_save("test.gif")