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,
color = NULL,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
text_cex = 1,
path = NULL,
path_width = 1,
path_color = "black",
guide = TRUE,
subpanel = FALSE
)
Arguments
- m
(required, numeric matrix) distance or cost matrix generated by
psi_distance_matrix()
orpsi_cost_matrix()
, but any numeric matrix will work. Default: NULL- 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 attributetype == "cost_path
, and must have been computed from the same sequences used to compute the matrixm
. 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"
- guide
(optional, logical) if TRUE, a color guide for the matrix
m
is added byutils_matrix_guide()
.- subpanel
(optional, logical) internal argument used when generating the multi-panel plot produced by
distantia_plot()
.
See also
Other internal_plotting:
utils_color_breaks()
,
utils_color_continuous_default()
,
utils_color_discrete_default()
,
utils_line_color()
,
utils_line_guide()
,
utils_matrix_guide()
Examples
#prepare time series list
tsl <- tsl_simulate(
n = 2,
independent = TRUE
)
#> distantia::zoo_name_set(): renaming zoo time series from 'A' to 'B'.
#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
)
}