| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/swatchplot.R |
| 3 |
\name{swatchplot} |
| 4 |
\alias{swatchplot} |
| 5 |
\title{Palette Swatch Plot} |
| 6 |
\usage{ |
| 7 |
swatchplot( |
| 8 |
x, |
| 9 |
..., |
| 10 |
nrow = 20, |
| 11 |
border = NULL, |
| 12 |
sborder = NULL, |
| 13 |
off = NULL, |
| 14 |
mar = NULL, |
| 15 |
line = NULL, |
| 16 |
cex = NULL, |
| 17 |
font = 1:2, |
| 18 |
cvd = FALSE |
| 19 |
) |
| 20 |
} |
| 21 |
\arguments{ |
| 22 |
\item{x}{character vector/matrix (or list of character vectors/matrices) |
| 23 |
containing color hex codes.} |
| 24 |
|
| 25 |
\item{\dots}{further (possibly named) character vectors/matrices with color |
| 26 |
hex codes.} |
| 27 |
|
| 28 |
\item{nrow}{integer specifying the maximal number of rows of swatches. |
| 29 |
(The actual number might be lower in order to balance the rows used in each column.)} |
| 30 |
|
| 31 |
\item{border}{color for border of individual color rectangles. By default |
| 32 |
\code{"lightgray"} for up to 9 colors, \code{"transparent"} otherwise.} |
| 33 |
|
| 34 |
\item{sborder}{color for border of the entire palette swatch. By default |
| 35 |
\code{"lightgray"} if \code{border} is \code{"transparent"} and \code{"lightgray"} |
| 36 |
otherwise (if \code{off = 0}).} |
| 37 |
|
| 38 |
\item{off}{numeric vector of length 2. Offset in horizontal and vertical direction |
| 39 |
(specified as a fraction of the rectangle for one color). By default, the |
| 40 |
horizontal offset is \code{0.3} for up to 5 colors and \code{0} otherwise, |
| 41 |
and the vertical offset is \code{0.1}.} |
| 42 |
|
| 43 |
\item{mar}{numeric vector of length 4, specifying the margins of column |
| 44 |
of color swatches.} |
| 45 |
|
| 46 |
\item{line}{numeric. Line in which the palette names (if any) are printed |
| 47 |
in the margin.} |
| 48 |
|
| 49 |
\item{cex, font}{numeric vectors of length 1 or 2. Specifications for the |
| 50 |
annotation text for the individual palettes and lists of palettes, respectively.} |
| 51 |
|
| 52 |
\item{cvd}{logical or character indicating whether color vision deficiencies |
| 53 |
should be emulated with \code{\link{desaturate}}, \code{\link{deutan}}, |
| 54 |
\code{\link{protan}}, \code{\link{tritan}}.} |
| 55 |
} |
| 56 |
\value{ |
| 57 |
\code{swatchplot} invisibly returns a matrix with colors and annotations. |
| 58 |
} |
| 59 |
\description{ |
| 60 |
Visualization of color palettes in columns of color swatches. |
| 61 |
} |
| 62 |
\details{ |
| 63 |
The function \code{swatchplot} is a convenience function for displaying |
| 64 |
collections of palettes that can be specified as lists or matrices of |
| 65 |
character color specifications. Essentially, the function just calls |
| 66 |
\code{\link[graphics]{rect}} but the value-added are the heuristics used |
| 67 |
for choosing default labels, margins, spacings, borders. These are selected |
| 68 |
to work well for \code{\link{hcl_palettes}} and might need further tweaking |
| 69 |
in future versions. |
| 70 |
} |
| 71 |
\examples{ |
| 72 |
## swatches of several palette vectors |
| 73 |
swatchplot( |
| 74 |
"Hue" = sequential_hcl(5, h = c(0, 300), c = c(60, 60), l = 65), |
| 75 |
"Chroma" = sequential_hcl(5, h = 0, c = c(100, 0), l = 65, rev = TRUE, power = 1), |
| 76 |
"Luminance" = sequential_hcl(5, h = 260, c = c(25, 25), l = c(25, 90), rev = TRUE, power = 1), |
| 77 |
off = 0 |
| 78 |
) |
| 79 |
|
| 80 |
## swatches of named palette matrices |
| 81 |
bprg <- c("Blues", "Purples", "Reds", "Greens") |
| 82 |
swatchplot( |
| 83 |
"Single-hue" = t(sapply(paste(bprg, 2), sequential_hcl, n = 7)), |
| 84 |
"Single-hue (advanced)" = t(sapply(paste(bprg, 3), sequential_hcl, n = 7)), |
| 85 |
"Multi-hue (advanced)" = t(sapply(bprg, sequential_hcl, n = 7)), |
| 86 |
nrow = 5 |
| 87 |
) |
| 88 |
|
| 89 |
## swatches with color vision deficiency emulation |
| 90 |
swatchplot(sequential_hcl(7, "Viridis"), cvd = TRUE) |
| 91 |
swatchplot( |
| 92 |
"YlGnBu" = sequential_hcl(7, "YlGnBu"), |
| 93 |
"Viridis" = sequential_hcl(7, "Viridis"), |
| 94 |
cvd = c("deutan", "desaturate") |
| 95 |
) |
| 96 |
} |
| 97 |
\references{ |
| 98 |
Zeileis A, Fisher JC, Hornik K, Ihaka R, McWhite CD, Murrell P, Stauffer R, Wilke CO (2020). |
| 99 |
\dQuote{colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes.} |
| 100 |
\emph{Journal of Statistical Software}, \bold{96}(1), 1--49. \doi{10.18637/jss.v096.i01} |
| 101 |
} |
| 102 |
\keyword{hplot} |