proto_highlight: Tour proto highlighing specified points

View source: R/2_ggproto_visualize.r

proto_highlightR Documentation

Tour proto highlighing specified points

Description

A geom_point or geom_segment(1d case) call to draw attention to a subset of points. This is mostly redundant proto_point with the implementation of the row_index argument on data protos, still helpful in the 1d case and for mark_initial, does not use bkg_row_color

Usage

proto_highlight(
  aes_args = list(),
  identity_args = list(color = "red", size = 5, shape = 8),
  row_index = 1,
  mark_initial = FALSE
)

proto_highlight1d(
  aes_args = list(),
  identity_args = list(color = "red", linetype = 2, alpha = 0.9),
  row_index = 1,
  mark_initial = FALSE
)

Arguments

aes_args

A list of arguments to call inside of aes(). aesthetic mapping of the primary geom. For example, geom_point(aes(color = my_fct, shape = my_fct)) becomes aes_args = list(color = my_fct, shape = my_fct).

identity_args

A list of static, identity arguments passed into geom_point(), but outside of aes(), for instance geom_point(aes(...), size = 2, alpha = .7) becomes identity_args = list(size = 2, alpha = .7). #' Typically a single numeric for point size, alpha, or similar.

row_index

A numeric or logical index of rows to subset to. Defaults to 1, highlighting the first row.

mark_initial

Logical, whether or not to leave a fainter mark at the subset's initial position. Defaults to FALSE.

See Also

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

Examples

library(spinifex)
dat     <- scale_sd(penguins_na.rm[, 1:4])
clas    <- penguins_na.rm$species
gt_path <- save_history(dat, grand_tour(), max_bases = 5)

## d = 2 case
ggt <- ggtour(gt_path, dat, angle = .3) +
  proto_default(aes_args = list(color = clas, shape = clas)) +
  proto_highlight(row_index = 5)

animate_plotly(ggt)


## Highlight multiple observations
ggt2 <- ggtour(gt_path, dat, angle = .3) +
  proto_default(aes_args = list(color = clas, shape = clas)) +
  proto_highlight(row_index = c( 2, 6, 19),
                  identity_args = list(color = "blue", size = 4, shape = 4))

animate_plotly(ggt2)

## 1D case:
gt_path1d <- save_history(dat, grand_tour(d = 1), max_bases = 3)

ggt <- ggtour(gt_path1d, dat, angle = .3) +
  proto_default1d(aes_args = list(fill = clas, color = clas)) +
  proto_highlight1d(row_index = 7)

animate_plotly(ggt)


## Highlight multiple observations, mark_initial defaults to off
ggt2 <- ggtour(gt_path1d, dat, angle = .3) +
  proto_default1d(aes_args = list(fill = clas, color = clas)) +
  proto_highlight1d(row_index = c(2, 6, 7),
                    identity_args = list(color = "green", linetype = 1))

animate_plotly(ggt2)


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