Skip to contents

This function is a simplified version of fields::imagePlot(), by Douglas Nychka. The original version is recommended in case more customization than the provided here is needed.

Usage

utils_matrix_plot(
  m = NULL,
  matrix_color = NULL,
  title = NULL,
  subtitle = NULL,
  xlab = NULL,
  ylab = NULL,
  text_cex = 1,
  path = NULL,
  path_width = 1,
  path_color = "black",
  diagonal_width = 1,
  diagonal_color = "white",
  guide = TRUE,
  subpanel = FALSE
)

Arguments

m

(required, numeric matrix) distance or cost matrix generated by psi_distance_matrix() or psi_cost_matrix(), but any numeric matrix will work. Default: NULL

matrix_color

(optional, character vector) vector of colors. Uses the palette "Zissou 1" by default. Default: NULL

title

(optional, character string) plot title. By default, names of the sequences used to compute the matrix m. Default: NULL

subtitle

(optional, character string) plot subtitle. Default: NULL

xlab

(optional, character string) title of the x axis (matrix columns). By default, the name of one of the sequences used to compute the matrix m. Default: NULL

ylab

(optional, character string) title of the y axis (matrix rows). By default, the name of one of the sequences used to compute the matrix m. Default: NULL

text_cex

(optional, numeric) multiplicator of the text size for the plot labels and titles. Default: 1

path

(optional, data frame) least cost path generated with psi_cost_path(). This data frame must have the attribute type == "cost_path, and must have been computed from the same sequences used to compute the matrix m. Default: NULL.

path_width

(optional, numeric) width of the least cost path. Default: 1

path_color

(optional, character string) color of the least-cost path. Default: "black"

diagonal_width

(optional, numeric) width of the diagonal. Set to 0 to remove the diagonal line. Default: 0.5

diagonal_color

(optional, character string) color of the diagonal. Default: "white"

guide

(optional, logical) if TRUE, a color guide for the matrix m is added by utils_matrix_guide().

subpanel

(optional, logical) internal argument used when generating the multi-panel plot produced by distantia_plot().

Value

plot

Examples

#prepare time series list
tsl <- tsl_simulate(
  n = 2,
  independent = TRUE
)

#distance matrix between time series
dm <- psi_distance_matrix(
  x = tsl[[1]],
  y = tsl[[2]]
)

#cost matrix
cm <- psi_cost_matrix(
  dist_matrix = dm
  )

#least cost path
cp <- psi_cost_path(
  dist_matrix = dm,
  cost_matrix = cm
)

#plot cost matrix and least cost path
if(interactive()){
  utils_matrix_plot(
    m = cm,
    path = cp,
    guide = TRUE
  )
}