% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/aaa.R
\name{color_ramp_continuous}
\alias{color_ramp_continuous}
\title{Map continuous values to colors}
\usage{
color_ramp_continuous(
  values,
  clim = range(values, na.rm = TRUE),
  cmap = grDevices::hcl.colors(11),
  ...
)
}
\arguments{
\item{values}{numeric vector of values to map to colors}

\item{clim}{length-two numeric vector giving the value range to map from;
values outside \code{[clim[1], clim[2]]} are clamped to the nearer endpoint
before mapping. Default is \code{range(values, na.rm = TRUE)}}

\item{cmap}{the color ramp to map onto: either a vector of colors (passed
to \code{\link[grDevices]{colorRamp}} to build the ramp function) or a
function such as the one returned by \code{\link[grDevices]{colorRamp}}
that takes a numeric vector with elements in \code{[0, 1]} and returns an
\code{n x 3} (or \code{n x 4}, with alpha) matrix of color-channel values
in \code{[0, 255]}. Default is \code{grDevices::hcl.colors(11)}}

\item{...}{passed to \code{\link[grDevices]{colorRamp}} when \code{cmap} is
a vector of colors (for example, \code{alpha = TRUE} to build an
alpha-aware ramp)}
}
\value{
A character vector of \code{'#RRGGBB'} (or \code{'#RRGGBBAA'})
color strings, the same length as \code{values}.
}
\description{
Linearly maps a numeric vector onto a color ramp, clamping values outside
the given range to the range's endpoints.
}
\examples{

x <- rnorm(100)
col <- color_ramp_continuous(x)

plot(x, col = col, pch = 16)


# Change color palettes with vector of colors
col <- color_ramp_continuous(
  x, cmap = c("lightgreen", "white", "pink"))
plot(x, col = col, pch = 16)

# Using colorRamp
col <- color_ramp_continuous(
  x, cmap = colorRamp(c("black", "orangered", "orange")))
plot(x, col = col, pch = 16)

# Using color ramp palette `function(n) { ... }`
col <- color_ramp_continuous(
  x, cmap = hcl.colors, palette = "Blue-Red 3")
plot(x, col = col, pch = 16)

# Set range
col <- color_ramp_continuous(
  x, clim = c(0, 1),
  cmap = c("black", "orangered", "orange"))
plot(x, col = col, pch = 16)



}
