Palettes {grDevices} | R Documentation |
Find red color palette Stock Images in HD and millions of other royalty-free stock photos, illustrations, and vectors in the Shutterstock collection. Thousands of.
Color Palettes
Description
Create a vector of
n
contiguous colors.Usage
Arguments
![Color Palette Vector Color Palette Vector](/uploads/1/2/6/2/126273670/827888891.png)
n | the number of colors (≥ 1) to be in thepalette. |
palette | a valid palette name (one of hcl.pals() ).The name is matched to the list of available palettes, ignoringupper vs. lower case, spaces, dashes, etc. in the matching. |
alpha | an alpha-transparency level in the range [0,1](0 means transparent and 1 means opaque), see argument alpha in hsv and hcl , respectively.Since R 4.0.0, a missing , i.e., not explicitly specifiedalpha is equivalent to alpha = NULL , which does notadd opacity codes ('FF' ) to the individual color hex codes. |
rev | logical indicating whether the ordering of the colors shouldbe reversed. |
fixup | logical indicating whether the resulting color should becorrected to RGB coordinates in [0,1], see hcl . |
type | the type of palettes to list: 'qualitative' ,'sequential' , 'diverging' , or 'divergingx' .NULL lists all palettes. |
s, v | the ‘saturation’ and ‘value’ to be usedto complete the HSV color descriptions. |
start | the (corrected) hue in [0,1] at which the rainbowbegins. |
end | the (corrected) hue in [0,1] at which the rainbow ends. |
Details
All of these functions (except the helper function
hcl.pals
) create avector of n
contiguous colors, either based on the HSV color space(rainbow, heat, terrain, topography, and cyan-magenta colors) or theperceptually-based HCL color space.HSV (hue-saturation-value) is a simple transformation of the RGB(red-green-blue) space which was therefore a convenient choice for colorpalettes in many software systems (see also
hsv
). However, HSVcolors capture the perceptual properties hue, colorfulness/saturation/chroma,and lightness/brightness/luminance/value only poorly and consequentlythe corresponding palettes are typically not a good choice for statisticalgraphics and data visualization.In contrast, HCL (hue-chroma-luminance) colors are much more suitable forcapturing human color perception (see also
hcl
) and better colorpalettes can be derived based on HCL coordinates.Conceptually, three types of palettes are often distinguished:- Qualitative: For coding categorical information, i.e., where noparticular ordering of categories is available and every color shouldreceive the same perceptual weight.
- Sequential: For coding ordered/numeric information, i.e., where colorsgo from high to low (or vice versa).
- Diverging: Designed for coding numeric information around a centralneutral value, i.e., where colors diverge from neutral to two extremes.
The
hcl.colors
function provides a basic and lean implementation ofthe pre-specified palettes in the colorspace package. In addition to thetypes above, the functions distinguish “diverging” palettes where the twoarms are restricted to be rather balanced as opposed to flexible“divergingx” palettes that combine two sequential palettes without anyrestrictions. The latter group also includes the cividis palette as it is basedon two different hues (blue and yellow) but it is actually a sequential palette(going from dark to light).The names of all available HCL palettes can be queried with the
hcl.pals
function and they are also visualized by color swatches in the examples. Many ofthe palettes closely approximate palettes of the same name from various otherpackages (including RColorBrewer, rcartocolor, viridis,scico, among others). The default HCL palette is the widely used viridis palette which is a sequentialpalette with relatively high chroma throughout so that it also works reasonablywell as a qualitative palette. However, while viridis is a rather robust defaultpalette, more suitable HCL palettes are available for most visualizations.
For example,
'Dark 3'
works well for shading points or lines inup to five groups, 'YlGnBu'
is a sequential palette similar to'viridis'
but with aligned chroma/luminance, and'Green-Brown'
or 'Blue-Red 3'
are colorblind-safediverging palettes.Further qualitative palettes are provided in the
palette.colors
function. While the qualitative palettes in hcl.colors
are always based on the same combination of chroma and luminance, the palette.colors
vary in chroma and luminance up to a certain degree. The advantage of fixing chroma/luminance is that the perceptual weight of the resulting colors is more balanced. The advantage of allowing variation is that more distinguishable colors can be obtained, especially for viewers with color vision deficiencies.Note that the
rainbow
function implements the (in-)famous rainbow (orjet) color palette that was used very frequently in many software packages buthas been widely criticized for its many perceptual problems.It is specified by a start
and end
hue with red = 0,yellow = 1/6, green = 2/6,cyan = 3/6, blue = 4/6, andmagenta = 5/6. However, these are very flashy and unbalancedwith respect to both chroma and luminance which can lead to various opticalillusions. Also, the hues that are equispaced in RGB space tend to cluster atthe red, green, and blue primaries. Therefore, it is recommended to use asuitable palette from hcl.colors
instead ofrainbow
.Value
A character vector
cv
containing either palette names (forhcl.pals
) or n
hex color codes (for all other functions).The latter can be used either to create a user-defined color palette forsubsequent graphics by palette(cv)
, a col =
specificationin graphics functions or in par
.References
Wikipedia (2019).HCL color space – Wikipedia, The Free Encyclopedia.https://en.wikipedia.org/w/index.php?title=HCL_color_space&oldid=883465135.Accessed March 26, 2019.
Zeileis, A., Fisher, J. C., Hornik, K., Ihaka, R., McWhite, C. D., Murrell, P., Stauffer, R. and Wilke, C. O. (2019).“colorspace: A toolbox for manipulating and assessing colors and palettes.”arXiv:1903.06490, arXiv.org E-Print Archive.http://arxiv.org/abs/1903.06490.
Ihaka, R. (2003).“Colour for presentation graphics.”Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003),March 20-22, 2003, Technische Universit채t Wien, Vienna, Austria.http://www.ci.tuwien.ac.at/Conferences/DSC-2003.
Zeileis, A., Hornik, K. and Murrell, P. (2009).Escaping RGBland: Selecting colors for statistical graphics.Computational Statistics & Data Analysis, 53, 3259–3270.doi: 10.1016/j.csda.2008.11.033.
See Also
colors
, palette
,gray.colors
,hsv
,hcl
, rgb
, gray
andcol2rgb
for translating to RGB numbers.