facet_wrap_tour: Wrap a 1d ribbon of panels into 2d for animation

View source: R/2_ggproto_visualize.r

facet_wrap_tourR Documentation

Wrap a 1d ribbon of panels into 2d for animation

Description

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.

Usage

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".

See Also

Other ggtour proto functions: append_fixed_y(), ggtour(), proto_basis(), proto_default(), proto_density(), proto_density2d(), proto_hex(), proto_highlight(), proto_hline0(), proto_origin(), proto_point(), proto_text()

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.")
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))
## Not run: 
animate_gganimate(ggt) ## May not always play well with plotly

## End(Not run)

spinifex documentation built on May 29, 2024, 1:23 a.m.