-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animation files not saved #93
Comments
The default is to return a magick object which can be saved with image_write() The plot method is currently down due to some patchwork issues |
Thank you. Perhaps that is worth mentioning in the README. |
Thank you both for this, but the returned object doesn't seem to be a magick object so I'm unable to save your example plot using library(ggplot2)
library(gganimate)
p <- ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
# Here comes the gganimate code
transition_states(
gear,
transition_length = 2,
state_length = 1
) +
enter_fade() +
exit_shrink() +
ease_aes('sine-in-out')
library(magick)
#> Linking to ImageMagick 6.9.9.39
#> Enabled features: cairo, fontconfig, freetype, lcms, pango, rsvg, webp
#> Disabled features: fftw, ghostscript, x11
image_write(p, 'test.gif')
#> Error: The 'image' argument is not a magick image object. Created on 2018-07-22 by the reprex Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.5.0 (2018-04-23)
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate en_GB.UTF-8
#> tz Europe/London
#> date 2018-07-22
#> Packages -----------------------------------------------------------------
#> package * version date source
#> assertthat 0.2.0 2017-04-11 CRAN (R 3.5.0)
#> backports 1.1.2 2017-12-13 CRAN (R 3.5.0)
#> base * 3.5.0 2018-04-24 local
#> bindr 0.1.1 2018-03-13 CRAN (R 3.5.0)
#> bindrcpp 0.2.2 2018-03-29 CRAN (R 3.5.0)
#> class 7.3-14 2015-08-30 CRAN (R 3.5.0)
#> classInt 0.2-3 2018-04-16 cran (@0.2-3)
#> colorspace 1.3-2 2016-12-14 CRAN (R 3.5.0)
#> compiler 3.5.0 2018-04-24 local
#> crayon 1.3.4 2017-09-16 CRAN (R 3.5.0)
#> datasets * 3.5.0 2018-04-24 local
#> DBI 1.0.0 2018-05-02 CRAN (R 3.5.0)
#> devtools 1.13.6 2018-06-27 CRAN (R 3.5.0)
#> digest 0.6.15 2018-01-28 CRAN (R 3.5.0)
#> dplyr 0.7.6 2018-06-29 CRAN (R 3.5.1)
#> e1071 1.6-8 2017-02-02 cran (@1.6-8)
#> evaluate 0.11 2018-07-17 CRAN (R 3.5.0)
#> farver 1.0 2018-07-21 Github (thomasp85/farver@d29b48c)
#> gdtools 0.1.7 2018-02-27 CRAN (R 3.5.0)
#> gganimate * 0.9.9.9999 2018-07-22 Github (thomasp85/gganimate@13a9a29)
#> ggplot2 * 3.0.0 2018-07-03 CRAN (R 3.5.0)
#> glue 1.3.0 2018-07-17 CRAN (R 3.5.0)
#> graphics * 3.5.0 2018-04-24 local
#> grDevices * 3.5.0 2018-04-24 local
#> grid 3.5.0 2018-04-24 local
#> gtable 0.2.0 2016-02-26 CRAN (R 3.5.0)
#> hms 0.4.2 2018-03-10 CRAN (R 3.5.0)
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.5.0)
#> knitr 1.20 2018-02-20 CRAN (R 3.5.0)
#> lazyeval 0.2.1 2017-10-29 CRAN (R 3.5.0)
#> lpSolve 5.6.13 2015-09-19 cran (@5.6.13)
#> magick * 1.9 2018-05-11 cran (@1.9)
#> magrittr 1.5 2014-11-22 CRAN (R 3.5.0)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
#> methods * 3.5.0 2018-04-24 local
#> munsell 0.5.0 2018-06-12 CRAN (R 3.5.0)
#> patchwork 0.0.1 2018-07-21 Github (thomasp85/patchwork@7fb35b1)
#> pillar 1.3.0 2018-07-14 CRAN (R 3.5.0)
#> pkgconfig 2.0.1 2017-03-21 CRAN (R 3.5.0)
#> plyr 1.8.4 2016-06-08 CRAN (R 3.5.0)
#> prettyunits 1.0.2 2015-07-13 cran (@1.0.2)
#> progress 1.2.0 2018-06-14 cran (@1.2.0)
#> purrr 0.2.5 2018-05-29 CRAN (R 3.5.0)
#> R6 2.2.2 2017-06-17 CRAN (R 3.5.0)
#> Rcpp 0.12.17 2018-05-18 CRAN (R 3.5.0)
#> rlang 0.2.1 2018-05-30 CRAN (R 3.5.0)
#> rmarkdown 1.10 2018-06-11 CRAN (R 3.5.0)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.5.0)
#> scales 0.5.0 2017-08-24 CRAN (R 3.5.0)
#> sf 0.6-3 2018-05-17 cran (@0.6-3)
#> spData 0.2.9.0 2018-06-17 cran (@0.2.9.0)
#> stats * 3.5.0 2018-04-24 local
#> stringi 1.2.4 2018-07-20 CRAN (R 3.5.0)
#> stringr 1.3.1 2018-05-10 CRAN (R 3.5.0)
#> svglite 1.2.1 2017-09-11 cran (@1.2.1)
#> tibble 1.4.2 2018-01-22 CRAN (R 3.5.0)
#> tidyselect 0.2.4 2018-02-26 CRAN (R 3.5.0)
#> tools 3.5.0 2018-04-24 local
#> transformr 0.1.0 2018-07-21 Github (thomasp85/transformr@f163c57)
#> tweenr 0.1.5.9999 2018-07-21 Github (thomasp85/tweenr@4d4f8d1)
#> units 0.6-0 2018-06-09 cran (@0.6-0)
#> utils * 3.5.0 2018-04-24 local
#> withr 2.1.2 2018-03-15 CRAN (R 3.5.0)
#> yaml 2.1.19 2018-05-01 CRAN (R 3.5.0) |
I had missed out the library(ggplot2)
library(gganimate)
p <- ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
# Here comes the gganimate code
transition_states(
gear,
transition_length = 2,
state_length = 1
) +
enter_fade() +
exit_shrink() +
ease_aes('sine-in-out')
image <- animate(p)
library(magick)
#> Linking to ImageMagick 6.9.9.39
#> Enabled features: cairo, fontconfig, freetype, lcms, pango, rsvg, webp
#> Disabled features: fftw, ghostscript, x11
image_write(image, 'test.gif') Created on 2018-07-22 by the reprex |
@thomasp85 Would you like me to add an example of saving an image file to the README? |
I'll do it - I still haven't finalised how this should work out in the end, e.g. if an equivalent of |
Sure, no problem. Thanks. |
Hi all, I am working on embedding animated gif into html report (though rendering .Rmd) and ran into the same issues as @gregrs-uk when saving image into .gif
Matrix products: default locale: attached base packages: other attached packages: loaded via a namespace (and not attached): |
There shouldn’t be any need for additional steps when embedding animations with rmarkdown. Just treat it like a regular ggplot |
Thanks, Thomas, it worked 🥇 |
Happy you got it to work😊 |
Just for any confused Linux people out there, I get the
error message with Ubuntu 16.04 but not with 17.10, I presume because of an older version of ImageMagick. I'm guessing to get it running on 16.04 you'll have to find another repository or compile from source. I haven't done this myself so I can't be sure. |
gganimate does not use ImageMagick in any way. It has changed default renderer to gifski which is why image_write no longer works and the returned object. anim_save() will always work no matter the renderer |
Aha. Apologies. I'll do that then. Thanks 😀 |
I am able to create animations in RStudio, but they are only displayed in the Viewer window.
I do not find any files containing the animation so I could use them outside of RStudio.
How can I "catch" the output file.
Also,
plot does work for my configuration (RStudio 1.2.805, R 3.5.1 MacOS 10.13.6)
Here is my example
and here is what I see when I try plot:
The text was updated successfully, but these errors were encountered: