Learn R Programming

tourr (version 1.1.0)

display_xy: Display tour path with a scatterplot

Description

Animate a 2D tour path with a scatterplot.

Usage

display_xy(
  center = TRUE,
  axes = "center",
  half_range = NULL,
  col = "black",
  pch = 20,
  cex = 1,
  edges = NULL,
  edges.col = "black",
  edges.width = 1,
  obs_labels = NULL,
  palette = "Zissou 1",
  ...
)

animate_xy(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, can be a factor or integer. Defaults to 20.

cex

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

edges

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

edges.col

colour of edges to be plotted, Defaults to "black"

edges.width

line width for edges, default 1

obs_labels

vector of text labels to display

palette

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

...

other arguments passed on to animate and display_xy

data

matrix, or data frame containing numeric columns

tour_path

tour path generator, defaults to 2d grand tour

Examples

Run this code
animate_xy(flea[, 1:6])
animate(flea[, 1:6], tour_path = grand_tour(), display = display_xy())
animate(flea[, 1:6],
  tour_path = grand_tour(),
  display = display_xy(),
  scale = TRUE
)
animate(flea[, 1:6],
  tour_path = grand_tour(),
  display = display_xy(half_range = 0.5)
)
animate_xy(flea[, 1:6], tour_path = little_tour())
animate_xy(flea[, 1:3], tour_path = guided_tour(holes()), sphere = TRUE)
animate_xy(flea[, 1:6], center = FALSE)

# The default axes are centered, like a biplot, but there are other options
animate_xy(flea[, 1:6], axes = "bottomleft")
animate_xy(flea[, 1:6], axes = "off")
animate_xy(flea[, 1:6], dependence_tour(c(1, 2, 1, 2, 1, 2)),
  axes = "bottomleft"
)

animate_xy(flea[, -7], col = flea$species)
animate_xy(flea[, -7], col = flea$species,
             pch = flea$species)

animate_xy(flea[, -7], col = flea$species,
  obs_labels=as.character(1:nrow(flea)), axes="off")

# You can also draw lines
edges <- matrix(c(1:5, 2:6), ncol = 2)
animate(
  flea[, 1:6], grand_tour(),
  display_xy(axes = "bottomleft", edges = edges)
)

Run the code above in your browser using DataLab