Skip to contents

An implementation of the Sage Tour described in Laa et al., 2021. It uses a radial transformation on the projected data so that the relative volume is preserved when the data is projected. I.e. a uniform distribution in the original space will remain uniformly distributed in the projected space. Includes both 2D and 3D variations.

Usage

show_sage(
  x,
  ...,
  palette = viridis,
  center = TRUE,
  axes = TRUE,
  edges = NULL,
  paused = TRUE,
  scale_factor = NULL,
  gamma = 1,
  R = NULL
)

Arguments

x

a detour object

...

used to support aesthetic parameters for the plot, including

  • size: point size, defaults to 1

  • alpha: point opacity, defaults to 1

  • background_colour: defaults to "white"

palette

Colour palette to use with the colour aesthetic. Can be:

  • A character vector of R colours. This should match the number of levels of the colour aesthetic, or the number of bins to use for continuous colours.

  • A function which takes the number of colours to use as input and returns a character vector of colour names and / or hex values as output.

center

If TRUE, center the projected data to (0, 0, 0).

axes

Can be one of:

  • TRUE draw axes and use column names for axis labels

  • FALSE do not draw axes or labels

  • NULL draw axes with no labels

  • An unnamed vector of labels with the same length as cols

  • A named vector in the form c("h" = "head"), where head is renamed to h

edges

A two column numeric matrix giving indices of ends of lines.

paused

whether the widget should be initialised in the 'paused' state

scale_factor

used as a multiplier for the point coordinates so they are displayed on a sensible range. Defaults to the reciprocal of maximum distance from a point to the origin.

gamma

the gamma parameter for scaling the effective dimensionality for the sage tour radial transformation. defaults to 1

R

scale for the radial transformation. Defaults to scale_factor times the maximum distance from the origin to each row of data. If the default scale_factor is used this will result in R=1. Because the R and scale_factor parameters interact with one another, it is recommended to leave scale_factor at its default value, and modify R if needed.

Value

An object of class htmlwidget

Details

This display method produces an interactive scatterplot animation which supports both 2D and 3D tours. Linked selection and filtering is also supported using crosstalk. The set of interactive controls available are:

  • A timeline with a play / pause button and indicators at the position of each basis used. The basis indicators can be hovered with the mouse to show the index of the basis, or clicked to jump to that basis. The timeline also allows for clicking and dragging of the scrubber to move to any individual frame of the animation.

  • Orbit controls. For the 2D variant, this allows the projection to be rotated by clicking and dragging from left to right. For the 3D variant, full orbit controls are available by clicking and dragging. For both orbit and pan controls, the scroll wheel can be used to zoom.

  • Pan controls, which work similarly to orbit controls but move the camera laterally / vertically rather than rotating

  • Resetting of the orbit and pan controls

  • Selection and highlighting. Multiple selection is possible by using the shift key

  • Colouring / brushing of highlighted points

References

Laa, U., Cook, D., & Lee, S. (2021). Burning sage: Reversing the curse of dimensionality in the visualization of high-dimensional data. Journal of Computational and Graphical Statistics, 1-10.

See also

show_scatter

Examples

detour(tourr::flea, tour_aes(projection = -species, colour = species)) |>
  tour_path(grand_tour(3), fps = 60) |>
  show_sage(gamma = 2)