Most basic animation with R and Image Magick



This post describes how to build a basic count down .gif animation. It uses R to make 10 images, and Image Magick to concatenated them in a .gif.

Animation Section About line chart

This is probably the most basic animated plot (.gif format) you can do with R and Image Magick.

  • Start by building 10 images with R
  • Use Image magick to concatenate them in a gif

Of course, Image Magick must be installed on your computer. See here to install it.

Note: : This example has been found on Mark Heckmann’s R you ready website.

# Build 10 images -> save them at .png format
png(file="example%02d.png", width=480, height=480)
par(bg="grey")
  for (i in c(10:1, "G0!")){
    plot.new()
    text(.5, .5, i, cex = 6 )
  }
dev.off()

# Use image magick
system("convert -delay 80 *.png animated_count_down.gif")

# Remove png files
file.remove(list.files(pattern=".png"))

Related chart types


Line plot
Area
Stacked area
Streamchart
Time Series



Contact

This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message on Twitter, or send an email pasting yan.holtz.data with gmail.com.

Github Twitter