Learn R Programming

tmap (version 0.6)

animation_tmap: Create animations

Description

This function creates a gif or mpeg animation from a tm plot. The free tool ImageMagick is required.

Usage

animation_tmap(expr, width = 1000, height = 1000, delay = 40,
  filename = "animation.gif")

Arguments

expr
R expression to create series of tm plots. In order to create a series of plots, which are combined to an animation, it is important to set nrow and ncol in tm_facets such that nrow * ncol < [number of sm
width
width of the animation file (in pixels)
height
height of the animation file (in pixels)
delay
delay time between images
filename
filename of the video (should be a .gif or .mpg file)

Examples

Run this code
data(Europe)

animation_tmap({
	tm_shape(Europe) +
		tm_fill("yellow") +
		tm_borders() +
		tm_facets(by = "name", nrow=1,ncol=1) +
		tm_layout(scale=2)
}, width=1200, height=800, filename="my_animation.gif")

Run the code above in your browser using DataLab