proto_density2d: Tour proto for data, 1D density, with rug marks

View source: R/2_ggproto_visualize.r

proto_density2dR Documentation

Tour proto for data, 1D density, with rug marks

Description

Adds geom_density_2d() of the projected data.

Usage

proto_density2d(
  aes_args = list(),
  identity_args = list(bins = 4),
  row_index = NULL
)

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 the primary geom. For instance, geom_point(size = 2, alpha = .7) becomes identity_args = list(size = 2, alpha = .7). Also passes more foundational arguments such as stat and position, though these have been tested less.

row_index

A numeric or logical index of rows to subset to. Defaults to NULL, all observations.

See Also

Other ggtour proto functions: append_fixed_y(), facet_wrap_tour(), ggtour(), proto_basis(), proto_default(), proto_density(), 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
gt_path <- save_history(dat, grand_tour(), max = 3)

## geom_density_2d args can be passed in identity_args (bins, binwidth, breaks) 
ggt <- ggtour(gt_path, dat, angle = .3) +
  proto_density2d(aes_args = list(color = clas, fill = clas),
                  identity_args = list(binwidth = .3)) +
  proto_point(aes_args = list(color = clas, shape = clas),
              identity_args = list(alpha = .2)) +
  proto_basis()

animate_plotly(ggt)


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