Created
June 11, 2018 11:23
-
-
Save thomasp85/9362bbfae956f2690794abeb2c11cdcc to your computer and use it in GitHub Desktop.
Preview of view_zoom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
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")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.