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
|
\name{findColours}
\alias{findColours}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{assign colours to classes from classInterval object}
\description{
This helper function is a wrapper for \code{findCols} to extract classes from a "classInterval" object and assign colours from a palette created by \code{colorRampPalette} from the two or more colours given in the \code{pal} argument. It also returns two attributes for use in constructing a legend.
}
\usage{
findColours(clI, pal, under="under", over="over", between="-",
digits = getOption("digits"), cutlabels=TRUE)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{clI}{a "classIntervals" object}
\item{pal}{a character vector of at least two colour names; \code{colorRampPalette} is used internally to create the required number of colours}
\item{under}{character string value for "under" in legend if cutlabels=FALSE}
\item{over}{character string value for "over" in legend if cutlabels=FALSE}
\item{between}{character string value for "between" in legend if cutlabels=FALSE}
\item{digits}{minimal number of significant digits in legend}
\item{cutlabels}{use cut-style labels in legend}
}
\value{
a character vector of colours with attributes: "table", a named frequency table; "palette", a character vector of colours corresponding to the specified breaks.
}
\author{Roger Bivand <Roger.Bivand@nhh.no}
\seealso{\code{\link{classIntervals}}, \code{\link{findInterval}}, \code{\link{findCols}}, \code{\link[grDevices]{colorRamp}}}
\examples{
if (!require("spData", quietly=TRUE)) {
message("spData package needed for examples")
run <- FALSE
} else {
run <- TRUE
}
if (run) {
data(jenks71, package="spData")
mypal <- c("wheat1", "red3")
h5 <- classIntervals(jenks71$jenks71, n=5, style="hclust", method="complete")
print(findColours(h5, mypal))
}
if (run) {
print(findColours(getHclustClassIntervals(h5, k=7), mypal))
}
if (run) {
h5Colours <- findColours(h5, mypal)
plot(h5, mypal, main="Complete hierarchical clustering")
legend(c(95, 155), c(0.12, 0.4), fill=attr(h5Colours, "palette"),
legend=names(attr(h5Colours, "table")), bg="white")
}
if (run) {
h5tab <- attr(h5Colours, "table")
legtext <- paste(names(h5tab), " (", h5tab, ")", sep="")
plot(h5, mypal, main="Complete hierarchical clustering (with counts)")
legend(c(95, 165), c(0.12, 0.4), fill=attr(h5Colours, "palette"),
legend=legtext, bg="white")
}
}
\keyword{spatial}
|