Skip to content
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

Cannot change resolution of output #15

Closed
phil-martin-research opened this issue Aug 30, 2016 · 8 comments
Closed

Cannot change resolution of output #15

phil-martin-research opened this issue Aug 30, 2016 · 8 comments

Comments

@phil-martin-research
Copy link

Great work on the package, it's really useful.

I'm putting together a gif to use in a presentation but can't work out if I can alter the resolution of the output from gg_animate(). Ideally, I'd like to be able to have a full screen .gif that isn't grainy.

Is there any way to alter the resolution of outputs in gganimate?

@yeedle
Copy link

yeedle commented Aug 30, 2016

Use the ani.width and ani.height arguments. #10

@gedankenstuecke
Copy link

Small hint: this only works if you're not specifying a file to write to. Just had this issue. For example gg_animate(plot,"output.mp4",ani.width=800, ani.height=400) will fail with an error.

For this you'll have to specify the width & height in ani.options, e.g.

ani.options(ani.width=800, ani.height=400)
gg_animate(plot,"output.mp4") 

Happy to update the docs to reflect that if that's wished.

@yeedle
Copy link

yeedle commented Sep 27, 2016

@gedankenstuecke, first, if you explicitly specify the filename argument it will work.

gg_animate(plot, filname = "output.mp4", ani.width=800, ani.height=400)

Alternatively, you can pass in the filename as the last argument, and it will work as well.

gg_animate(plot, ani.width=800, ani.height=400, "output.mp4")

@gedankenstuecke
Copy link

Ah, thanks! Then nevermind!

@jrosen48
Copy link

Hmm, I tried this, and got the following error message:

>gganimate(gg, filename = "test.gif", ani.width=1000, ani.height=800)
Error in check.options(new, name.opt = ".X11.Options", envir = .X11env) : 
  invalid argument names ‘ani.width’, ‘ani.height’ in 'grDevices::png(..., res = dpi, units = "in")'

@yeedle
Copy link

yeedle commented Feb 26, 2017

Yes, gganimate was updated since then. Instead, try this:

animation::ani.options(ani.width = 1000, ani.height = 800)
gganimate(gg, filename = "test.gif")

@xgirouxb
Copy link

AFAIK, given that the default for grDevices::png() is 72 ppi, adjusting the number of pixels (via ani.width and ani.height) used to draw an image only defines the dimensions of the output, not the resolution of the output. I fiddled around quite a bit and my outputs always seemed way too grainy. I googled around and found the following solution using the ani.res argument:

animation::ani.options(ani.width = 1000, ani.height = 800, ani.res = 300)
gganimate(gg, filename = "test.gif")

While this works great for me, the solution isn't obvious because ani.res is not listed in the documentation currently hosted on CRAN (dated 2017-03-30). It seems that the argument is brand new and is only included in the latest update of the animation package (rolled out a month ago). See the following conversation and feature request: yihui/animation#99

@dgrtwo
Copy link
Collaborator

dgrtwo commented Jul 5, 2018

We are finishing a complete rewrite of gganimate undertaken by Thomas Pedersen, with massive breaking changes to the API (this will come with a version bump to 1.0.0; currently 0.9.9.9999). This fixes many existing bugs and installation difficulties, and offers a more intuitive grammar of graphics.

As a result I'm closing almost all open issues, since they aren't relevant to the new version (bug reports in particular no longer apply). I apologize for any inconvenience in updating your existing code, but the new version of gganimate will be well worth the effort.

  • If you are still interested in this issue and believe it is relevant to the new version of gganimate, you can reopen it!

  • If you'd like to continue using the old gganimate version (which we do not recommend, as it will not be maintained), you can install from this release using the following code:

    devtools::install_github("dgrtwo/gganimate", ref = "v0.1.1”)
    

@dgrtwo dgrtwo closed this as completed Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants