| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/hclplot.R |
| 3 |
\name{hclplot} |
| 4 |
\alias{hclplot} |
| 5 |
\title{Palette Plot in HCL Space} |
| 6 |
\usage{ |
| 7 |
hclplot( |
| 8 |
x, |
| 9 |
type = NULL, |
| 10 |
h = NULL, |
| 11 |
c = NULL, |
| 12 |
l = NULL, |
| 13 |
xlab = NULL, |
| 14 |
ylab = NULL, |
| 15 |
main = NULL, |
| 16 |
cex = 1, |
| 17 |
axes = TRUE, |
| 18 |
bg = "white", |
| 19 |
lwd = 1, |
| 20 |
size = 2.5, |
| 21 |
... |
| 22 |
) |
| 23 |
} |
| 24 |
\arguments{ |
| 25 |
\item{x}{character vector containing color hex codes, or a \code{\link{color-class}} |
| 26 |
object.} |
| 27 |
|
| 28 |
\item{type}{type character specifying which type of palette should be visualized |
| 29 |
(\code{"qualitative"}, \code{"sequential"}, or \code{"diverging"}). |
| 30 |
For qualitative palettes a hue-chroma plane is used, otherwise a chroma-luminance plane. |
| 31 |
By default, the \code{type} is inferred from the luminance trajectory corresponding |
| 32 |
to \code{x}.} |
| 33 |
|
| 34 |
\item{h}{numeric hue(s) to be used for \code{type = "sequential"} and \code{type = "diverging"}. |
| 35 |
By default, these are inferred from the colors in \code{x}.} |
| 36 |
|
| 37 |
\item{c}{numeric. Maximal chroma value to be used.} |
| 38 |
|
| 39 |
\item{l}{numeric luminance(s) to be used for \code{type = "qualitative"}. |
| 40 |
By default, this is inferred from the colors in \code{x}.} |
| 41 |
|
| 42 |
\item{xlab, ylab, main}{character strings for annotation, by default generated from |
| 43 |
the type of color palette visualized.} |
| 44 |
|
| 45 |
\item{cex}{numeric character extension.} |
| 46 |
|
| 47 |
\item{axes}{logical. Should axes be drawn?} |
| 48 |
|
| 49 |
\item{bg, lwd, size}{graphical control parameters for the color palette trajectory.} |
| 50 |
|
| 51 |
\item{\dots}{currently not used.} |
| 52 |
} |
| 53 |
\value{ |
| 54 |
\code{hclplot} invisibly returns a matrix with the HCL coordinates corresponding to \code{x}. |
| 55 |
} |
| 56 |
\description{ |
| 57 |
Visualization of color palettes in HCL space projections. |
| 58 |
} |
| 59 |
\details{ |
| 60 |
The function \code{hclplot} is an auxiliary function for illustrating |
| 61 |
the trajectories of color palettes in two-dimensional HCL space projections. |
| 62 |
It collapses over one of the three coordinates (either the hue H or the |
| 63 |
luminance L) and displays a heatmap of colors combining the remaining |
| 64 |
two dimensions. The coordinates for the given color palette are highlighted |
| 65 |
to bring out its trajectory. |
| 66 |
|
| 67 |
The function \code{hclplot} has been designed to work well with the |
| 68 |
\code{\link{hcl_palettes}} in this package. While it is possible to apply |
| 69 |
it to other color palettes as well, the results might look weird or confusing |
| 70 |
if these palettes are constructed very differently (e.g., as in the highly |
| 71 |
saturated base R palettes). |
| 72 |
|
| 73 |
More specifically, the following palettes can be visualized well: \itemize{ |
| 74 |
\item Qualitative with (approximately) constant luminance. In this case, |
| 75 |
\code{hclplot} shows a hue-chroma plane (in polar coordinates), keeping |
| 76 |
luminance at a fixed level (by default displayed in the main title of |
| 77 |
the plot). If the luminance is, in fact, not approximately constant, |
| 78 |
the luminance varies along with hue and chroma, using a simple linear |
| 79 |
function (fitted by least squares). |
| 80 |
\code{hclplot} shows a chroma-luminance plane, keeping hue at a fixed |
| 81 |
level (by default displayed in the main title of the plot). If the hue |
| 82 |
is, in fact, not approximately constant, the hue varies along with |
| 83 |
chroma and luminance, using a simple linear function (fitted by least |
| 84 |
squares. |
| 85 |
\item Diverging with two (approximately) constant hues: This case is |
| 86 |
visualized with two back-to-back sequential displays. |
| 87 |
} |
| 88 |
To infer the type of display to use, by default, the following heuristic is |
| 89 |
used: If luminance is not approximately constant (range > 10) and follows |
| 90 |
rougly a triangular pattern, a diverging display is used. If luminance is |
| 91 |
not constant and follows roughly a linear pattern, a sequential display is |
| 92 |
used. Otherwise a qualitative display is used. |
| 93 |
} |
| 94 |
\examples{ |
| 95 |
## for qualitative palettes luminance and chroma are fixed, varying only hue |
| 96 |
hclplot(qualitative_hcl(9, c = 50, l = 70)) |
| 97 |
|
| 98 |
## single-hue sequential palette (h = 260) with linear vs. power-transformed trajectory |
| 99 |
hclplot(sequential_hcl(7, h = 260, c = 80, l = c(35, 95), power = 1)) |
| 100 |
hclplot(sequential_hcl(7, h = 260, c = 80, l = c(35, 95), power = 1.5)) |
| 101 |
|
| 102 |
## advanced single-hue sequential palette with triangular chroma trajectory |
| 103 |
## (piecewise linear vs. power-transformed) |
| 104 |
hclplot(sequential_hcl(7, h = 245, c = c(40, 75, 0), l = c(30, 95), power = 1)) |
| 105 |
hclplot(sequential_hcl(7, h = 245, c = c(40, 75, 0), l = c(30, 95), power = c(0.8, 1.4))) |
| 106 |
|
| 107 |
## multi-hue sequential palette with small hue range and triangular chroma vs. |
| 108 |
## large hue range and linear chroma trajectory |
| 109 |
hclplot(sequential_hcl(7, h = c(260, 220), c = c(50, 75, 0), l = c(30, 95), power = 1)) |
| 110 |
hclplot(sequential_hcl(7, h = c(260, 60), c = 60, l = c(40, 95), power = 1)) |
| 111 |
|
| 112 |
## balanced diverging palette constructed from two simple single-hue sequential |
| 113 |
## palettes (for hues 260/blue and 0/red) |
| 114 |
hclplot(diverging_hcl(7, h = c(260, 0), c = 80, l = c(35, 95), power = 1)) |
| 115 |
|
| 116 |
} |
| 117 |
\references{ |
| 118 |
Zeileis A, Fisher JC, Hornik K, Ihaka R, McWhite CD, Murrell P, Stauffer R, Wilke CO (2020). |
| 119 |
\dQuote{colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes.} |
| 120 |
\emph{Journal of Statistical Software}, \bold{96}(1), 1--49. \doi{10.18637/jss.v096.i01} |
| 121 |
} |
| 122 |
\seealso{ |
| 123 |
\code{\link{specplot}} |
| 124 |
} |
| 125 |
\keyword{hplot} |