View source: R/2_ggproto_visualize.r
| proto_density | R Documentation | 
Adds geom_density() and geom_rug() of the projected data. Density
postion = "stack" does not work with animate_plotly(), GH issue is open.
proto_density(
  aes_args = list(),
  identity_args = list(alpha = 0.7),
  row_index = NULL,
  density_position = c("identity", "stack", "fill"),
  rug_shape = c(3, 142, 124, NULL)
)
aes_args | 
 A list of arguments to call inside of aes().
aesthetic mapping of the primary geom. For example,
  | 
identity_args | 
 A list of static, identity arguments passed into
the primary geom. For instance,
  | 
row_index | 
 A numeric or logical index of rows to subset to. Defaults to NULL, all observations.  | 
density_position | 
 The   | 
rug_shape | 
 Numeric, the number of the shape to make rug marks. Expects either 3 142, 124 or NULL, '+', '|' (plotly), '|' (ggplot2) respectively. Defaults to 3.  | 
Other ggtour proto functions: 
append_fixed_y(),
facet_wrap_tour(),
ggtour(),
proto_basis(),
proto_default(),
proto_density2d(),
proto_hex(),
proto_highlight(),
proto_hline0(),
proto_origin(),
proto_point(),
proto_text()
library(spinifex)
dat  <- scale_sd(penguins_na.rm[, 1:4])
clas <- penguins_na.rm$species
## Manual tour
bas <- basis_olda(dat, clas)
mt  <- manual_tour(bas, manip_var = 2)
ggt <- ggtour(mt, dat, angle = .3) +
  proto_density(aes_args = list(color = clas, fill = clas)) +
  proto_basis1d() +
  proto_origin1d()
animate_plotly(ggt)
## Grand tour
gt_path <- save_history(dat, grand_tour(), max = 3)
ggt <- ggtour(gt_path, dat, angle = .3) +
  proto_density(aes_args = list(color = clas, fill = clas)) +
  proto_basis1d() +
  proto_origin1d()
animate_plotly(ggt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.