Description Usage Arguments Examples
View source: R/display-density2d.r
Animate a 2D tour path with density contour(s) and a scatterplot.
1 2 3 4 5 | display_density2d(center = TRUE, axes = "center", half_range = NULL,
col = "black", pch = 20, contour_quantile = c(0.6827, 0.9545),
edges = NULL, ...)
animate_density2d(data, tour_path = grand_tour(), ...)
|
center |
if TRUE, centers projected data to (0,0). This pins the center of data cloud and make it easier to focus on the changing shape rather than position. |
axes |
position of the axes: center, bottomleft or off |
half_range |
half range to use when calculating limits of projected. If not set, defaults to maximum distance from origin to each row of data. |
col |
color to be plotted. Defaults to "black". Each unique color is given a new group of contours. |
pch |
shape of the point to be plotted. Defaults to 20. |
contour_quantile |
vector of quantiles to plot the contours at. Defaults to c(.68, .95). |
edges |
A two column integer matrix giving indices of ends of lines. |
... |
other arguments passed on to |
data |
matrix, or data frame containing numeric columns |
tour_path |
tour path generator, defaults to 2d grand tour |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | animate_density2d(flea[, 1:6])
animate(flea[, 1:6], tour_path=grand_tour(), display=display_density2d())
animate(flea[, 1:6], tour_path=grand_tour(),
display=display_density2d(axes = "bottomleft"))
animate(flea[, 1:6], tour_path=grand_tour(),
display=display_density2d(half_range = 0.5))
animate_density2d(flea[, 1:6], tour_path=little_tour())
animate_density2d(flea[, 1:3], tour_path=guided_tour(holes), sphere = TRUE)
animate_density2d(flea[, 1:6], center = FALSE)
# The default axes are centered, like a biplot, but there are other options
animate_density2d(flea[, 1:6], axes = "bottomleft")
animate_density2d(flea[, 1:6], axes = "off")
animate_density2d(flea[, 1:6], dependence_tour(c(1, 2, 1, 2, 1, 2)),
axes = "bottomleft")
require(colorspace)
pal <- rainbow_hcl(length(levels(flea$species)))
col <- pal[as.numeric(flea$species)]
pch <- as.numeric(flea$species)+14
animate_density2d(flea[,-7], col=col, pch = pch)
# You can also draw lines
edges <- matrix(c(1:5, 2:6), ncol = 2)
animate(flea[, 1:6], grand_tour(),
display_density2d(axes = "bottomleft", edges = edges))
# or change the contour quantiles
animate_density2d(flea[, 1:6], col = col, pch = pch, contour_quantile = c(.25, .5, .75))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.