Specify an animation from a tmap plot. This is similar to creating facets with tm_facets(). The animation subsequently can be exported to a gif or video file (e.g. mp4) with tmap_animation(). If the tmap plot with tm_animate() is printed, the animation will be previewed. The default tm_animate() will show the individual frames slowly (frame per seconds (fps) set to 2) whereas tm_animate_fast() will show them like a movie (with a fps set to 24).
Arguments
- frames
group by variable used to create the animation frames. This is similar to the
byargument oftm_facets_wrap(). Instead of showing facets next to each other, they are shown as animation frames. However, under the hoodframeswill be used to specifypagesoftm_facets(). This makes it possible to create an animation of regular facets.- nframes
number of animation frames. So far, this only applied experimentally in transition map variables. See the extension package tmap.cartogram.
- fps
frames per second. Default: 30 for
tm_facets_animateand 2 fortm_facets_animate_slow.- play
how should the animation be played? One of
"loop"(default),"pingpong", and"once", where"loop"means that the animation will loop indefinitely,"pingpong"means that it will play forward and then backward, and"once"means that it will play only once.- dpr
device pixel ratio. The ratio between the physical pixel density of a device and its logical pixel density.
- ...
passed on to
tm_facets(). Note that for animated facets,bycan be specified to create animated facet wraps, androwsandcolsto created animated facet grids.
Note
In older versions (< 4.1) tm_facets() with page specification was used to create animations frames and tmap_animation() to create the animation itself using inputs like the frame rate specification. As of version 4.2, the whole animation, including frame rate, is specified in tm_animate(). The animation can still be saved via tmap_animation().
See also
tm_facets() which is the core function, and tmap_animation() used to save the animation
