Commit 15040eca authored by Corson N. Areshenkoff's avatar Corson N. Areshenkoff

Add spd.heatmap

parent 09119b35
......@@ -11,6 +11,7 @@ export(spddot)
export(spd.whiten)
export(spd.correlation)
export(spd.transport)
export(spd.heatmap)
importFrom(expm,expm)
importFrom(expm,logm)
......
#' Heatmap of an SPD matrix
#'
#' Function plots a heatmap of a matrix. Currently, the function is not particularly
#' featureful, and any customization should be done by passing additional arguments
#' to levelplot through \code{...}.
#' @param V A numeric matrix of autoregressive coefficients with targets as
#' rows and sources as columns.
#' @param labs An optional character vector of labels. If NULL, the row and
#' column names of V are used.
#' @param ... Additional arguments to levelplot
#' @return NA
spd.heatmap <- function(V, labs = NULL, ...){
# Set dimnames
if (!is.null(labs)){
colnames(V) <- labs
rownames(V) <- labs
}
# Set colors
col.lims <- range(V)
color.ramp.length <- 20
negative.length <- round(abs(col.lims)[1] / diff(col.lims) * color.ramp.length)
positive.length <- color.ramp.length - negative.length
cols <- c(colorRampPalette(c("blue", "white"))(negative.length),
colorRampPalette(c("white", "red"))(positive.length))
# Plot
colorkey <- list(col = cols, at = do.breaks(col.lims, color.ramp.length))
par(mar=c(3,4,2,2))
levelplot(t(V), col.regions = cols, colorkey = colorkey, ...)
}
......@@ -4,7 +4,7 @@
\alias{spd.expmap}
\title{Projection from the tangent space}
\usage{
spd.expmap(x, p)
spd.expmap(x, p = NULL)
}
\arguments{
\item{x}{A symmetric matrix}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spd-heatmap.R
\name{spd.heatmap}
\alias{spd.heatmap}
\title{Heatmap of an SPD matrix}
\usage{
spd.heatmap(V, labs = NULL, col.scale = NULL, ...)
}
\arguments{
\item{V}{A numeric matrix of autoregressive coefficients with targets as rows and sources as columns.}
\item{labs}{An optional character vector of labels. If NULL, the row and column names of V are used.}
}
\value{
NA
}
\description{
Function plots a heatmap of vector autoregressive coefficients. Currently,
plotting options are limited to the default settings.
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment