Skip to contents

Plots a spot matrix.

Usage

plot_spot(object, ...)

# S4 method for matrix
plot_spot(
  object,
  type = c("ring", "plain"),
  threshold = NULL,
  diag = TRUE,
  upper = TRUE,
  lower = TRUE,
  freq = FALSE,
  ...
)

# S4 method for data.frame
plot_spot(
  object,
  type = c("ring", "plain"),
  threshold = NULL,
  diag = TRUE,
  upper = TRUE,
  lower = TRUE,
  freq = FALSE,
  ...
)

# S4 method for dist
plot_spot(
  object,
  type = c("ring", "plain"),
  diag = FALSE,
  upper = FALSE,
  lower = !upper,
  ...
)

Arguments

object

A \(m \times p\) numeric matrix or data.frame of count data (absolute frequencies giving the number of individuals for each class).

...

Extra parameters to be passed to threshold.

type

A character string specifying the graph to be plotted. It must be one of "ring" (the default) or "plain". Any unambiguous substring can be given.

threshold

A function that takes a numeric vector as argument and returns a numeric threshold value. If NULL (the default), no threshold is computed.

diag

A logical scalar indicating whether the diagonal of the matrix should be plotted. Only used if object is a symmetric matrix.

upper

A logical scalar indicating whether the upper triangle of the matrix should be plotted. Only used if object is a symmetric matrix.

lower

A logical scalar indicating whether the lower triangle of the matrix should be plotted. Only used if object is a symmetric matrix.

freq

A logical scalar indicating whether relative frequency should be used instead of counts (absolute frequency).

Value

A ggplot2::ggplot object.

Details

The spot matrix can be considered as a variant of the Bertin diagram where the data are first transformed to relative frequencies.

Note

Adapted from Dan Gopstein's original idea.

Author

N. Frerebeau

Examples

## Data from Conkey 1980, Kintigh 1989
data("cantabria")

## Plot spot diagram of count data...
### ...without threshod
plot_spot(cantabria)

### ...with the  column means as threshold
plot_spot(cantabria, threshold = mean)

### ...with the column medians as threshold
plot_spot(cantabria, threshold = median)