114122, 652 PM [RPubs -Exporing 30 graphs fom ‘attic’ as rotating GIF images
RPUubs wastucio Signin | Regis
hitpssitpubs.comib_t cooperatice_rotaion_80 12114122, 652 PM ;RPubs - Exporting 3 graphs trom lattice’ as rotating GIF images
Exporting 3D graphs from ‘lattice’ as
rotating GIF images
Ben Cooper
1 November 2016
This code is designed to generate a 3D plot using the wireframe() function in the lattice package, and export it
to an animated image performing an orbital rotation. Whilst | found a multitude of ways of making interactively
rotatable 3D figures within R, | could not find a satisfying workflow for exporting them. So here we are.
The following packages are required:
Library(1attice)
Library (animation)
4 Warning: package ‘animation’ was built under R version 3.2.4
Our first job is of course to create the graph in question. This can be any graph plotted using wireframe() - for
demonstration purposes, | will use the volcano data that comes with R.
wireframe(volcano, shade = TRUE, distance=0,
screenzlist(z=50,x=-60),
ylabe"", z1al
xial scales-List(draw=FALSE))
hitpsa/tpubs.comb_t_cooperfatice_rotation_30
22