| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/rainbow_hcl.R |
| 3 |
\name{rainbow_hcl} |
| 4 |
\alias{rainbow_hcl} |
| 5 |
\alias{heat_hcl} |
| 6 |
\alias{terrain_hcl} |
| 7 |
\alias{diverging_hsv} |
| 8 |
\alias{diverge_hsv} |
| 9 |
\title{HCL (and HSV) Color Palettes Corresponding to Base R Palettes} |
| 10 |
\usage{ |
| 11 |
rainbow_hcl( |
| 12 |
n, |
| 13 |
c = 50, |
| 14 |
l = 70, |
| 15 |
start = 0, |
| 16 |
end = 360 * (n - 1)/n, |
| 17 |
gamma = NULL, |
| 18 |
fixup = TRUE, |
| 19 |
alpha = 1, |
| 20 |
... |
| 21 |
) |
| 22 |
|
| 23 |
heat_hcl( |
| 24 |
n, |
| 25 |
h = c(0, 90), |
| 26 |
c. = c(100, 30), |
| 27 |
l = c(50, 90), |
| 28 |
power = c(1/5, 1), |
| 29 |
gamma = NULL, |
| 30 |
fixup = TRUE, |
| 31 |
alpha = 1, |
| 32 |
... |
| 33 |
) |
| 34 |
|
| 35 |
terrain_hcl( |
| 36 |
n, |
| 37 |
h = c(130, 0), |
| 38 |
c. = c(80, 0), |
| 39 |
l = c(60, 95), |
| 40 |
power = c(1/10, 1), |
| 41 |
gamma = NULL, |
| 42 |
fixup = TRUE, |
| 43 |
alpha = 1, |
| 44 |
... |
| 45 |
) |
| 46 |
|
| 47 |
diverging_hsv( |
| 48 |
n, |
| 49 |
h = c(240, 0), |
| 50 |
s = 1, |
| 51 |
v = 1, |
| 52 |
power = 1, |
| 53 |
gamma = NULL, |
| 54 |
fixup = TRUE, |
| 55 |
alpha = 1, |
| 56 |
... |
| 57 |
) |
| 58 |
} |
| 59 |
\arguments{ |
| 60 |
\item{n}{the number of colors (\eqn{\ge 1}{>= 1}) to be in the palette.} |
| 61 |
|
| 62 |
\item{c, c.}{chroma value in the HCL color description.} |
| 63 |
|
| 64 |
\item{l}{luminance value in the HCL color description.} |
| 65 |
|
| 66 |
\item{start}{the hue at which the rainbow begins.} |
| 67 |
|
| 68 |
\item{end}{the hue at which the rainbow ends.} |
| 69 |
|
| 70 |
\item{gamma}{Deprecated.} |
| 71 |
|
| 72 |
\item{fixup}{logical. Should the color be corrected to a valid RGB value |
| 73 |
before correction?} |
| 74 |
|
| 75 |
\item{alpha}{numeric vector of values in the range \code{[0, 1]} for alpha |
| 76 |
transparency channel (0 means transparent and 1 means opaque).} |
| 77 |
|
| 78 |
\item{\dots}{Other arguments passed to \code{\link{hex}}.} |
| 79 |
|
| 80 |
\item{h}{hue value in the HCL or HSV color description, has to be in [0, 360] |
| 81 |
for HCL and in [0, 1] for HSV colors.} |
| 82 |
|
| 83 |
\item{power}{control parameter determining how chroma and luminance should |
| 84 |
be increased (1 = linear, 2 = quadratic, etc.).} |
| 85 |
|
| 86 |
\item{s}{saturation value in the HSV color description.} |
| 87 |
|
| 88 |
\item{v}{value value in the HSV color description.} |
| 89 |
} |
| 90 |
\value{ |
| 91 |
A character vector with (s)RGB codings of the colors in the palette. |
| 92 |
} |
| 93 |
\description{ |
| 94 |
Color palettes based on the HCL (and HSV) color space to replace |
| 95 |
base R palettes. |
| 96 |
} |
| 97 |
\details{ |
| 98 |
Based on the general qualitative, sequential, and diverging \code{\link{hcl_palettes}} |
| 99 |
within the colorspace package, convenience functions are provided as |
| 100 |
alternatives to standard base R palettes (which are highly saturated |
| 101 |
and too flashy). |
| 102 |
|
| 103 |
\code{rainbow_hcl} computes a rainbow of colors via \code{\link{qualitative_hcl}} |
| 104 |
defined by different hues given a single value of each chroma and luminance. |
| 105 |
It corresponds to \code{\link{rainbow}} which computes a rainbow in HSV |
| 106 |
space. |
| 107 |
|
| 108 |
\code{heat_hcl} is an implementation of \code{\link[grDevices]{heat.colors}} in |
| 109 |
HCL space based on a call to \code{\link{sequential_hcl}}. Similarly, |
| 110 |
\code{terrain_hcl} palette also calls \code{sequential_hcl} with different |
| 111 |
parameters, providing colors similar in spirit to \code{terrain.colors} |
| 112 |
in HCL space. |
| 113 |
|
| 114 |
\code{diverging_hsv} (and equivalently its alias \code{diverge_hsv}) |
| 115 |
provides an HSV-based version of \code{\link{diverging_hcl}}. Its purpose |
| 116 |
is mainly didactic to show that HSV-based diverging palettes are less |
| 117 |
appealing, more difficult to read and more flashy than HCL-based diverging |
| 118 |
palettes. \code{diverging_hsv} is similar to \code{\link[grDevices]{cm.colors}}. |
| 119 |
} |
| 120 |
\examples{ |
| 121 |
## convenience demo function |
| 122 |
wheel <- function(col, radius = 1, ...) |
| 123 |
pie(rep(1, length(col)), col = col, radius = radius, ...) |
| 124 |
|
| 125 |
## compare base and colorspace palettes |
| 126 |
## (in color and desaturated) |
| 127 |
par(mar = rep(0, 4), mfrow = c(2, 2)) |
| 128 |
## rainbow color wheel |
| 129 |
wheel(rainbow_hcl(12)) |
| 130 |
wheel(rainbow(12)) |
| 131 |
wheel(desaturate(rainbow_hcl(12))) |
| 132 |
wheel(desaturate(rainbow(12))) |
| 133 |
|
| 134 |
## diverging red-blue colors |
| 135 |
swatchplot( |
| 136 |
diverging_hsv(7), |
| 137 |
desaturate(diverging_hsv(7)), |
| 138 |
diverging_hcl(7, c = 100, l = c(50, 90)), |
| 139 |
desaturate(diverging_hcl(7, c = 100, l = c(50, 90))), |
| 140 |
nrow = 2 |
| 141 |
) |
| 142 |
|
| 143 |
## diverging cyan-magenta colors |
| 144 |
swatchplot( |
| 145 |
cm.colors(7), |
| 146 |
desaturate(cm.colors(7)), |
| 147 |
diverging_hcl(7, "Cyan-Magenta"), ## or, similarly: Tropic |
| 148 |
desaturate(diverging_hcl(7, "Cyan-Magenta")), |
| 149 |
nrow = 2 |
| 150 |
) |
| 151 |
|
| 152 |
## heat colors |
| 153 |
swatchplot( |
| 154 |
heat.colors(12), |
| 155 |
desaturate(heat.colors(12)), |
| 156 |
heat_hcl(12), |
| 157 |
desaturate(heat_hcl(12)), |
| 158 |
nrow = 2 |
| 159 |
) |
| 160 |
|
| 161 |
## terrain colors |
| 162 |
swatchplot( |
| 163 |
terrain.colors(12), |
| 164 |
desaturate(terrain.colors(12)), |
| 165 |
terrain_hcl(12), |
| 166 |
desaturate(terrain_hcl(12)), |
| 167 |
nrow = 2 |
| 168 |
) |
| 169 |
} |
| 170 |
\references{ |
| 171 |
Zeileis A, Hornik K, Murrell P (2009). Escaping RGBland: |
| 172 |
Selecting Colors for Statistical Graphics. \emph{Computational Statistics & |
| 173 |
Data Analysis}, \bold{53}, 3259--3270. |
| 174 |
\doi{10.1016/j.csda.2008.11.033} |
| 175 |
Preprint available from |
| 176 |
\url{https://www.zeileis.org/papers/Zeileis+Hornik+Murrell-2009.pdf}. |
| 177 |
|
| 178 |
Stauffer R, Mayr GJ, Dabernig M, Zeileis A (2015). Somewhere over the |
| 179 |
Rainbow: How to Make Effective Use of Colors in Meteorological |
| 180 |
Visualizations. \emph{Bulletin of the American Meteorological Society}, |
| 181 |
\bold{96}(2), 203--216. |
| 182 |
\doi{10.1175/BAMS-D-13-00155.1} |
| 183 |
} |
| 184 |
\seealso{ |
| 185 |
\code{\link[colorspace]{polarLUV}}, \code{\link[colorspace]{HSV}}, |
| 186 |
\code{\link[colorspace]{hex}} |
| 187 |
} |
| 188 |
\keyword{color} |