Carries out mapping between assorted color spaces including RGB, HSV, HLS, CIEXYZ, CIELUV, HCL (polar CIELUV), CIELAB and polar CIELAB. Qualitative, sequential, and diverging color palettes based on HCL colors are provided along with corresponding ggplot2 color scales. Color palette choice is aided by an interactive app (with either a Tcl/Tk or a shiny GUI) and shiny apps with an HCL color picker and a color vision deficiency emulator. Plotting functions for displaying and assessing palettes include color swatches, visualizations of the HCL space, and trajectories in HCL and/or RGB spectrum. Color manipulation functions include: desaturation, lightening/darkening, mixing, and simulation of color vision deficiencies (deutanomaly, protanomaly, tritanomaly).
Major update of the package that enhances many of its capabilities, e.g., more refined palettes, named palettes, ggplot2 color scales, visualizations for assessing palettes, more and enhanced shiny and Tcl/Tk apps, color vision deficiency emulation, and much more. See below for further details. A new web site presenting and documenting the package has been launched at http://colorspace.R-Forge.R-project.org/
Claus O. Wilke and Claire D. McWhite joined the colorspace team, adding and enhancing various features, including (but not limited to) especially the color vision deficiency emulation, the ggplot2 palettes, and new shiny apps.
simulate_cvd() for simulating color vision deficiencies
with convenience interfaces
hcl_palettes() to query pre-defined HCL-based palettes:
qualitative, sequential (single-hue), sequential (multi-hue),
diverging. The corresponding
can help to explore the palettes.
Pre-defined HCL palettes are taken from previous publications about colorspace as well as approximations from other packages (ColorBrewer.org, CARTO, viridis, scico).
o Users can also register their own custom color palettes for subsequent
usage (within the same session) in
diverging_hcl() using the
register = "..." argument. To generally
make such custom palettes available, a registration R code a la
colorspace::qualitative_hcl(..., register = "myname") can be placed in
.Rprofile or similar startup scripts. Also the
app allows to register palettes in the current session.
New and more flexible
qualitative_hcl() palette function. This is
similar to the old
rainbow_hcl() but allows to use the pre-defined
palettes and change the parameters more easily.
sequential_hcl() is now substantially more flexible:
encompasses both single-hue and multi-hue palettes; gained a new
cmax for non-monotonic chroma paths. Parameters
cmax allow to easily modify
existing palettes in just a few HCL parameters.
diverging_hcl() is introduced as a copy of
for a more consistent naming of the *_hcl palettes where * is one of
the adjectives "qualitative", "sequential", and "diverging". Both
diverge_hcl() now also gained a
sequential_hcl(). Individual parameters
p2 can also be easily modified.
divergex_hcl() have been added for
fully fle_x_ible diverging palettes (as opposed to the more restricted
balanced palettes in
diverge_hcl()). These support parameters
Many new predefined palettes that facilitate close approximation of almost all palettes from ColorBrewer.org/RColorBrewer, CARTO/rcartocolor, and viridis. Additionally, approximations to a few of Fabio Crameri's scientific color maps (scico) are available as well.
New interactive shiny app
hcl_color_picker() - or equivalently,
choose_color() - for exploring HCL colors, and manually assembling
individual colors or palettes. Douglas C. Wu (@wckdouglas) provided the
original implementation for the color palette feature.
darken() for programatically lightening
and darkening colors.
New convenience function
swatchplot() that facilitates displaying
color swatches to display and compare collections of color palettes.
specplot() gained an argument
y=NULL to optionally display a second
palette and compare their trajectories. By default,
only shows the HCL spectrum but not the RGB spectrum (
rgb = FALSE)
because it is mainly used for illustrating and comparing properties
of HCL-based palettes.
hclplot() for visualizing trajectories of color palettes
in two-dimensional HCL space projections.
demoplot() that makes the demonstration plots (map,
heatmap, pie, lines, etc.) from the
app available outside the GUI on the command line.
Added a new function
max_chroma() that (approximately) computes
the maximum chroma possible for a given hue and luminance
combination in HCL space.
Registration of C routines.
LAB_to_XYZ conversion, replace decimal approximations with exact
rational numbers (reported by Glenn Davis). Follows Bruce Lindbloom:
whitepoint() that can both query the current whitepoint
and set it to a different value. By default CIE D65 with XYZ
coordinates 95.047, 100.000, 108.883 is used. But it is possible
to set another global whitepoint now, used for all conversions in
the package (suggested by Glenn Davis).
Fixed a bug in
desaturate() for named colors (such as
where erroneously the
RGB() rather than
sRGB() model was used
desaturate(..., amount = 1) for optional partial
as_HLS(), which was passing
coloras the colour to convert (and that was producing not only wrong results, but random results because the values in
answere not initialized). Thanks to Thomas Julou for the report.
In addition to the Tcl/Tk-based GUI for
choose_palette() there is now
a shiny-based GUI.
choose_palette() by default still uses the Tcl/Tk
hclwizard() is a new wrapper that by default calls the
new shiny version.
specplot() that converts a given palette in hex codes
to RGB and HCL coordinates and visualizes their spectrum as a line
hex2RGB() now omits the alpha channel (if any) in the hex colors
choose_palette() for sequential palettes with multiple hues:
Now two palettes are included in the examples that are very close
to "viridis" and "magma" from matplotlib in Python (also available
in R via package viridis)
Changed Depends/Imports/Suggests to conform with current R CMD check.
choose_palette()when using palette functions with optional alpha channels.
Alpha channel is preserved in desaturate for named colors (especially
NA). (Reported by Simon Potter.)
Added alpha argument for all palette functions (see
Small fixups for R CMD check.
hex2RGB()now. (Reported by Richard Cotton.)
New Tcl/Tk-based GUI for choosing different types of palettes:
rainbow_hcl), single-hue sequential (
multi-hue sequential (
heat_hcl), and diverging (
GUI provides a wide collection of pre-stored palettes, easy
manipulation of the corresponding arguments, illustration through
a broad range of plot types (maps, heatmaps, variations of bar plots,
scatter plots, and many more), emulation of desaturation and
dichromatic vision, loading/saving palettes, etc.
Bug fix in
.Call() calls now with
PACKAGE = "colorspace".
Added some simple tests based on the examples and vignette.
desaturate() function for removal of chroma in a given
vector of colors.
Bug fix in
HLS_to_RGB conversion for
s == 0.
RGB colorspace is linearized "sRGB".)
Conversions to and from
HSL can only occur
from or to
sRGB (because both
are relative colorspaces, meaning relative to a particular
(Converting to or from
RGB gives a different result
compared to conversion to or from
gamma parameters in all R-level functions have been deprecated.
sRGB colorspace has implicit gamma.)
Moved color palettes from vcd to colorspace, including
Added infrastructure for HLS color space
New CITATION file