Learn R Programming

spinifex (version 0.3.2)

animate_plotly: Animate a ggtour as and HTML widget via {plotly}

Description

Animates the static ggtour() and added proto_*() functions as a {plotly} animation, an .html widget with slider and hover tooltip showing the row number.

Usage

animate_plotly(ggtour, fps = 8, ...)

Arguments

ggtour

A grammar of graphics tour with appended protos added. A return from ggtour() + proto_*().

fps

Scalar number of Frames Per Second, the speed the animation should play at.

...

Other arguments passed to plotly::ggplotly.

See Also

Other ggtour animator: animate_gganimate(), filmstrip()

Examples

Run this code
# NOT RUN {
library(spinifex)
dat     <- scale_sd(penguins[, 1:4])
clas    <- penguins$species
bas     <- basis_pca(dat)
mv      <- manip_var_of(bas)
mt_path <- manual_tour(bas, manip_var = mv)

ggt <- ggtour(mt_path, dat, angle = .3) +
  proto_origin() +
  proto_basis() +
  proto_point(aes_args = list(color = clas, shape = clas),
              identity_args = list(size = 1.5, alpha = .7))
# }
# NOT RUN {
animate_plotly(ggt, width = 700, height = 450) ## pixels only, no resolution argument

## Example saving to a .html widget, may require additional setup.
if(F){
  anim <- animate_plotly(ggt, fps = 10,
                         width = 700, height = 450) ## in pixels
  
  htmlwidgets::saveWidget(widget = anim,
                          file = "./figures/my_tour.html",
                          selfcontained = TRUE)}
# }

Run the code above in your browser using DataLab