opar = par(mar = c(4, 4, 0.2, 0.2))
oopt = ani.options(interval = 0.1, nmax = 50)
# use default arguments (random numbers); you may try to find the real data
Rosling.bubbles()
# rectangles
Rosling.bubbles(rectangles = matrix(abs(rnorm(50 * 10 * 2)), ncol = 2))
# save the animation in HTML pages
ani.options(ani.height = 450, ani.width = 600,
title = "The Bubbles Animation in Hans Rosling's Talk",
description = "An imitation of Hans Rosling's moving bubbles.")
ani.start()
par(mar = c(4, 4, 0.2, 0.2))
# with 'years' as the background
Rosling.bubbles(text = 1951:2000)
ani.stop()
ani.options(oopt)
par(opar)
Run the code above in your browser using DataLab