Animate a 2D tour path with density contour(s) and a scatterplot.

display_density2d(
  center = TRUE,
  axes = "center",
  half_range = NULL,
  col = "black",
  pch = 20,
  cex = 1,
  contour_quartile = c(0.25, 0.5, 0.75),
  edges = NULL,
  palette = "Zissou 1",
  ...
)

animate_density2d(data, tour_path = grand_tour(), ...)

Arguments

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 use for points, can be a vector or hexcolors or a factor. Defaults to "black".

pch

shape of the point to be plotted. Defaults to 20.

cex

size of the point to be plotted. Defaults to 1.

contour_quartile

Vector of quartiles to plot the contours at. Defaults to 5.

edges

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

palette

name of color palette for point colour, used by hcl.colors, default "Zissou 1"

...

other arguments passed on to animate and display_density2d

data

matrix, or data frame containing numeric columns

tour_path

tour path generator, defaults to 2d grand tour

Examples

animate_density2d(flea[, 1:6])
#> Converting input data to the required matrix format.
#> Using half_range 66



animate(flea[, 1:6], tour_path = grand_tour(), display = display_density2d())
#> Converting input data to the required matrix format.
#> Using half_range 66



animate(flea[, 1:6],
  tour_path = grand_tour(),
  display = display_density2d(axes = "bottomleft")
)
#> Converting input data to the required matrix format.
#> Using half_range 66



animate(flea[, 1:6],
  tour_path = grand_tour(),
  display = display_density2d(half_range = 0.5)
)
#> Converting input data to the required matrix format.



animate_density2d(flea[, 1:6], tour_path = little_tour())
#> Converting input data to the required matrix format.
#> Using half_range 66




animate_density2d(flea[, 1:3], tour_path = guided_tour(holes()), sphere = TRUE)
#> Converting input data to the required matrix format.
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> Value  1.582   0.0 % better 
#> No better bases found after 25 tries.  Giving up.
#> Final projection: 
#> -0.766  0.239  
#> -0.601  -0.596  
#> 0.228  -0.767  
#> Using half_range 65



animate_density2d(flea[, 1:6], center = FALSE)
#> Converting input data to the required matrix format.
#> Using half_range 323




# The default axes are centered, like a biplot, but there are other options
animate_density2d(flea[, 1:6], axes = "bottomleft")
#> Converting input data to the required matrix format.
#> Using half_range 66



animate_density2d(flea[, 1:6], axes = "off")
#> Converting input data to the required matrix format.
#> Using half_range 66



animate_density2d(flea[, 1:6], dependence_tour(c(1, 2, 1, 2, 1, 2)),
  axes = "bottomleft"
)
#> Converting input data to the required matrix format.
#> Using half_range 66




animate_density2d(flea[, -7], col = flea$species)
#> Converting input data to the required matrix format.
#> Using half_range 66


# 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)
)
#> Converting input data to the required matrix format.
#> Using half_range 66