Create and wrap a 1d ribbon of panels in 2d. Because of the side effects of ggtour and facet_wrap_tour this wants to be applied after ggtour and before any proto_* functions. plotly may not display well with with faceting.

facet_wrap_tour(facet_var, nrow = NULL, ncol = NULL, dir = "h")

Arguments

facet_var

Expects a single variable to facet the levels of. Should be a vector, not a formula (~cyl) or ggplot2::vars() call.

nrow

Number of rows. Defaults to NULL; set by display dim.

ncol

Number of columns. Defaults to NULL; set by display dim.

dir

Direction of wrapping: either "h" horizontal by rows, or "v", for vertical by columns. Defaults to "h".

Examples

library(spinifex)
dat     <- scale_sd(penguins_na.rm[, 1:4])
clas    <- penguins_na.rm$species
bas     <- basis_pca(dat)
mv      <- manip_var_of(bas)
mt_path <- manual_tour(bas, manip_var = mv)

## d = 2 case
message("facet_wrap_tour wants be called early, so that other proto's adopt the facet_var.")
#> facet_wrap_tour wants be called early, so that other proto's adopt the facet_var.
ggt <- ggtour(mt_path, dat, angle = .3) +
  facet_wrap_tour(facet_var = clas, ncol = 2, nrow = 2) +
  proto_default(aes_args = list(color = clas, shape = clas),
                identity_args = list(size = 1.5))
# \donttest{
animate_gganimate(ggt) ## May not always play well with plotly
# }