1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
% $Id: colorbar.Rd 25 2022-05-30 18:46:01Z proebuck $
\name{colorbar}
\alias{colorbar}
\title{MATLAB colorbar function}
\description{
Displays colorbar showing the color scale.
}
\usage{
colorbar(C, location=c("EastOutside", "WestOutside", "NorthOutside", "SouthOutside"), \dots)
}
\arguments{
\item{C}{numeric vector or matrix representing data values}
\item{location}{character scalar indicating desired orientation with respect
to the axes}
\item{\dots}{graphical parameters for \link[graphics]{image} may also be
passed as arguments to this method}
}
\details{
The values of the elements of \code{C} are indices into the current
\link[grDevices]{palette} that determine the color of each patch.
This implementation differs a bit from its MATLAB counterpart in that
the values must be passed explicitly.
}
\author{
P. Roebuck \email{proebuck1701@gmail.com}
}
\seealso{
\code{\link{imagesc}},
\code{\link{jet.colors}},
\code{\link[graphics]{layout}},
\code{\link[graphics]{par}}
}
\examples{
doPlot <- function(C,
cb.loc=c("EastOutside",
"WestOutside",
"NorthOutside",
"SouthOutside"),
...) {
saved.par <- par(no.readonly=TRUE)
on.exit(par(saved.par))
layout.EO <- function() {
## divide the device into one row and nine columns
## allocate figure 1 the first eight columns
## allocate figure 2 the last column
layout(matrix(c(1, 1, 1, 1, 1, 1, 1, 1, 2), ncol=9))
}
layout.WO <- function() {
## divide the device into one row and nine columns
## allocate figure 1 the last eight columns
## allocate figure 2 the first column
layout(matrix(c(2, 1, 1, 1, 1, 1, 1, 1, 1), ncol=9))
}
layout.NO <- function() {
## divide the device into six rows and one column
## allocate figure 1 the last five rows
## allocate figure 2 the first row
layout(matrix(c(2, 1, 1, 1, 1, 1), nrow=6))
}
layout.SO <- function() {
## divide the device into six rows and one column
## allocate figure 1 the first five rows
## allocate figure 2 the last row
layout(matrix(c(1, 1, 1, 1, 1, 2), nrow=6))
}
location <- match.arg(cb.loc)
switch(EXPR=location,
EastOutside = layout.EO(),
WestOutside = layout.WO(),
NorthOutside = layout.NO(),
SouthOutside = layout.SO())
imagesc(C, ...)
colorbar(C, location, ...)
}
values <- matrix(c(seq(1, 5, by=1),
seq(2, 10, by=2),
seq(3, 15, by=3)), nrow=3, byrow=TRUE)
dev.new(width=8, height=7)
doPlot(values, "EastOutside", col=jet.colors(16))
}
\keyword{hplot}
|