Color Space Manipulation

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 an interactive palette picker (with either a Tcl/Tk or a shiny GUI).


Changes in Version 1.3-2

o Fixed error in as_HLS(), which was passing 'ans' rather than 'color' as the colour to convert (and that was producing not only wrong results, but random results because the values in 'ans' were not initialized). Thanks to Thomas Julou for the report.

Changes in Version 1.3-1

o Fixed erroneous use of "return" rather than "return()" in choose_palette()/hclwizard().

Changes in Version 1.3-0

o 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 version while hclwizard() is a new wrapper that by default calls the new shiny version.

o New function specplot() that converts a given palette in hex codes to RGB and HCL coordinates and visualizes their spectrum as a line plot.

o hex2RGB() now omits the alpha channel (if any) in the hex colors provided.

Changes in Version 1.2-7

o Extended 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")

o Changed Depends/Imports/Suggests to conform with current R CMD check.

Changes in Version 1.2-6

o Moved "tcltk" again from Imports to Suggests to facilitate usage of colorspace on platforms where tcltk is not available.

Changes in Version 1.2-5

o Changed Depends/Imports/Suggests to conform with current R CMD check.

Changes in Version 1.2-4

o Bug fix for choose_palette() when using palette functions with optional alpha channels.

Changes in Version 1.2-3

o Alpha channel is preserved in desaturate for named colors (especially "transparent" and NA). (Reported by Simon Potter.)

o Added alpha argument for all palette functions (see ?rainbow_hcl).

o Small fixups for R CMD check.

Changes in Version 1.2-2

o Names of colors are preserved in hex() and hex2RGB() now. (Reported by Richard Cotton.)

Changes in Version 1.2-1

o If a new version of the dichromat package (> 1.2-4) with tritan support is found, this is interfaced in choose_palette().

Changes in Version 1.2-0

o New Tcl/Tk-based GUI for choosing different types of palettes: qualitative (rainbow_hcl), single-hue sequential (sequential_hcl), multi-hue sequential (heat_hcl), and diverging (diverge_hcl). The 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.

o Bug fix in polarLAB_to_LAB conversion.

o All .Call() calls now with PACKAGE = "colorspace".

o Added some simple tests based on the examples and vignette.

Changes in Version 1.1-1

o Added desaturate() function for removal of chroma in a given vector of colors.

o Bug fix in HLS_to_RGB conversion for s == 0.

Changes in Version 1.1-0

o Added "sRGB" colorspace. (Existing "RGB" colorspace is linearized "sRGB".)

o Conversions to and from "HSV" and "HSL" can only occur from or to "RGB" or "sRGB" (because both "HSV" and "HSL" are relative colorspaces, meaning relative to a particular RGB colorspace). (Converting to or from "RGB" gives a different result compared to conversion to or from "sRGB".)

o All 'gamma' parameters in all R-level functions have been deprecated. (The "sRGB" colorspace has implicit gamma.)

Changes in Version 1.0-1

o "Escaping RGBland" paper is now published Computational Statistics & Data Analysis as doi:10.1016/j.csda.2008.11.033. Citation and references updated accordingly.

Changes in Version 1.0-0

o new version to accompany the "Escaping RGBland" paper accepted for publication in Computational Statistics & Data Analysis, see citation("colorspace")

Changes in Version 0.97

o moved color palettes from vcd to colorspace, including vignette("hcl-colors")

o added infrastructure for HLS color space

o new CITATION file

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.3-2 by Achim Zeileis, 9 months ago

Browse source code at

Authors: Ross Ihaka [aut], Paul Murrell [aut], Kurt Hornik [aut], Jason C. Fisher [aut], Reto Stauffer [aut], Achim Zeileis [aut, cre]

Documentation:   PDF Manual  

Task views: Graphic Displays & Dynamic Graphics & Graphic Devices & Visualization

BSD_3_clause + file LICENSE license

Imports graphics, grDevices

Depends on methods

Suggests datasets, stats, utils, KernSmooth, MASS, kernlab, mvtnorm, vcd, dichromat, tcltk, shiny, shinyjs

Imported by BayesX, CHNOSZ, DepthProc, DiffusionRgqd, DiffusionRimp, DiffusionRjgqd, HH, HistDAWass, IsotopeR, JBTools, NMF, NetOrigin, OpenRepGrid, Polychrome, RSurvey, RcmdrMisc, SGP, TIMP, Wats, anacor, arulesViz, bea.R, canprot, cds, circlize, colorpatch, copula, corr2D, dexter, effects, epicontacts, extracat, forecast, ftsa, gdimap, geiger, genotypeR, ggthemes, gpairs, heatmaply, mafs, mapStats, mcmcplots, metafolio, msr, munsell, optimization, pals, plotKML, qgraph, rainbow, randomcoloR, semPlot, seriation, simPop, simsalapar, smacof, smoothAPC, subspace, trackeR, treemap, vcd.

Depended on by BiplotGUI, R2BayesX, RcmdrPlugin.SM, VIM, ViSiElse, W2CWM2C, bamlss, biclust, coloc, frontiles, ips, mixAK, paramGUI, prefmod, snpStatsWriter, spacodiR, tourrGui.

Suggested by DEoptim, LBSPR, OpenStreetMap, RGraphics, Radviz, RandomFields, Rcmdr, SWMPr, WRS2, aqp, cba, collapsibleTree, dendextend, dynamichazard, emojifont, flexsurv, gamlss.util, grImport, httk, inlmisc, longCatEDA, mlt.docreg, movMF, netmeta, nodiv, nonrandom, party, psychotree, rasterVis, rattle, recmap, regsem, surveillance, tourr, viridis.

Enhanced by Rgnuplot, shades.

See at CRAN