matrix_plot {qrmtools} | R Documentation |
Plot of a matrix.
matrix_plot(x, ylim = rev(c(0.5, nrow(x) + 0.5)), xlab = "Column", ylab = "Row", scales = list(alternating = c(1,1), tck = c(1,0), x = list(at = pretty(1:ncol(x)), rot = 90), y = list(at = pretty(1:nrow(x)))), at = NULL, colorkey = NULL, col = c("royalblue3", "white", "maroon3"), col.regions = NULL, ...)
x |
|
ylim |
y-axis limits in reverse order (for the rows to appear 'top down'). |
xlab |
x-axis label. |
ylab |
y-axis label. |
scales |
|
at |
see |
colorkey |
see |
col |
|
col.regions |
see |
... |
additional arguments passed to the underlying
|
Plot of a matrix.
The plot, a Trellis object.
Marius Hofert
## Generate a random correlation matrix d <- 50 L <- diag(1:d) set.seed(271) L[lower.tri(L)] <- runif(choose(d,2)) # random Cholesky factor Sigma <- L P <- cor(Sigma) ## Default matrix_plot(P) matrix_plot(abs(P)) # if nonnegative L. <- L diag(L.) <- NA matrix_plot(L.) # Cholesky factor without diagonal ## Default if nonpositive matrix_plot(-abs(P)) ## Extending the color key to [-1,1] with darker color for |rho| >> 0 ## Note: When specifying 'at', one most likely also wants 'col.regions' matrix_plot(P, at = seq(-1, 1, length.out = 200), col.regions = grey(c(seq(0, 1, length.out = 100), seq(1, 0, length.out = 100)))) ## An example with overlaid lines library(lattice) my_panel <- function(...) { panel.levelplot(...) panel.abline(h = c(10, 20), v = c(10, 20), lty = 2) } matrix_plot(P, panel = my_panel)