thomasp85 / gganimate

A Grammar of Animated Graphics
https://gganimate.com
Other
1.95k stars 309 forks source link

convert argument too long #47

Closed espinielli closed 6 years ago

espinielli commented 7 years ago

I tried to gganimate a full day of flights over Europe. I did plot a density 2d of position report for every minute in a day. So I have 1440 Rplot<x>.png images for convert to put together in an animated gif.

Here is the code:

map <- get_map(location=c(lon=15.0, lat=50.0),zoom = 4, color='bw')
files_csv <- dir("data/", pattern = "2017-02-21_..\\.csv", full.names = TRUE)
bm <- import_fr24_csv(files_csv) # a dataframe w/ cols: frame, lon, lat
p <- ggmap(map) +
  geom_density_2d(data = bm, aes(x = lon, y = lat, frame = frame))
gganimate(p, filename = "2017-02-21-1min.gif", title_frame = FALSE)

But I get the following error:

Executing: 
"convert -loop 0 -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png
    Rplot7.png Rplot8.png Rplot9.png Rplot10.png Rplot11.png Rplot12.png Rplot13.png Rplot14.png
    Rplot15.png Rplot16.png Rplot17.png Rplot18.png Rplot19.png Rplot20.png Rplot21.png Rplot22.png
    Rplot23.png Rplot24.png Rplot25.png Rplot26.png Rplot27.png Rplot28.png Rplot29.png Rplot30.png
    ...    
    Rplot606.png Rplot607.png Rplot608.png Rplot609.png RpThe command line is too long.
    an error occurred in the conversion... see Notes in ?im.convert
    ....

I have been able to generate the animated GIF manually from the temporarily create PNG's with a workaround I found here, i.e. ImageMagick can avoid the "Argument too long" issue with the underlying shell by using its own filename globbing method, hence the "*.png" (note the quotes ")

$ convert -loop 0 -delay 10 "*.png" ~/anim.gif

but to properly get the right sequence of PNG's I had to overcome one shortcoming of the package (or the dependent ones):

My (manual) solution was to zero pad the relevant files in order to have Rplot0001.png, Rplot0002.png ... Rplot1440.png.

In summary the issue I faced could require the following 2 changes:

johnmackintosh commented 6 years ago

I had a similar issue (trying to generate plots minute by minute over 24 hours) and it kept failing with similar error messages received the command line being too long. My solution was to break each plot into 15 minute timebands and plot cumulatively from time 0 to the end of each 15 minute segment.
That way I only had to generate 96 plots, rather than 1440. Not sure if this will suit you but just putting it out there for anyone else who may come across this

dgrtwo commented 6 years ago

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.