Utilities for Using Munsell Colours

Provides easy access to, and manipulation of, the Munsell colours. Provides a mapping between Munsell's original notation (e.g. "5R 5/10") and hexadecimal strings suitable for use directly in R graphics. Also provides utilities to explore slices through the Munsell colour tree, to transform Munsell colours and display colour palettes.


The munsell package provides easy access to, and manipulation of, the Munsell colours. The munsell package provides a mapping between Munsell's orginal notation (e.g. "5R 5/10") and hexidecimal sRGB strings suitable for use directly in R graphics. The package also provides utilities to explore slices through the Munsell colour tree, to transform Munsell colours and display colour palettes.

Munsell devised his system of colour notation to match the three percetual dimensions of colour: hue, value and chroma. His notation provides a naming scheme to colours that eases the choice of color according to a specific purpose. His century old advice is still relevent for the producers of statistical graphics and the munsell package aims to enable user to easily follow it.

Functions in munsell fall into three basic use categories: specifying Munsell colours, altering Munsell colours and exploring the Munsell color space.

The code below relies on the development version of munsell, get it with:

devtools::install_github("cwickham/munsell")

Following Munsell, specifying colours is done with a specific string format: "H V/C" where H is a hue code (see mnsl_hues() for a list of those available, excluding "N"), V an integer in ([0, 10]) specifying value, and C an even integer specifying chroma. The mnsl function takes the string and returns a hexadecimal RGB representation:

library(munsell)
mnsl("5R 5/10")

Visually examining a colour can either be done by using mnsl with a base plotting call, or using plot_mnsl which plots colour swatches using ggplot2:

plot.new()
rect(0, 0, 1 ,1 , col = mnsl("5R 5/10"))
plot_mnsl("5R 5/10")

munsell provides convenience functions that alter a colour by taking steps in the hue, value and chroma dimensions: rygbp, pbgyr, lighter, darker, saturate and desaturate.

my_blue <- "5PB 5/8"
p <- plot_mnsl(c(
  lighter(my_blue, 2),      my_blue,   darker(my_blue, 2),
  desaturate(my_blue, 2),   my_blue,   saturate(my_blue, 2),
  rygbp(my_blue, 2),        my_blue,   pbgyr(my_blue, 2)))
p

Each function optionally takes the number of steps to take in the dimension and consequently are easily used to create scales in a particular dimension.

p <- plot_mnsl(sapply(0:6, darker, col = "5PB 7/4"))
p + ggplot2::facet_wrap(~ num, nrow = 1)

Slices through the colour space of constant hue, chroma or value can be displayed using the functions: hue_slice, chroma_slice and value_slice. Additionally complement_slice displays a slice of constant hue, alongside a slice of its complement, the hue that is on the opposite side of the colour sphere to that specified.

complement_slice("5R")

News

Version 0.4.3

  • many fixes to remove R CMD check notes/warnings fixes issue (#5)

  • fix bug that gave incorrect greys

  • add functions rygbp and pbgyr to change the hue of a colour

  • add function mnsl2hvc to pull apart a munsell string

  • reimplement altering functions to make use of mnsl2hvc and hvc2mnsl

  • fix plot_mnsl to show multiple swatches of identical colour

  • lighter, darker, saturate and desaturate take an additional argument 'steps' to specify how many steps to take.

Version 0.4.2

  • hues with zero chroma are now defined but are named using the corresponding grey (i.e. 5B 0/4 is equivalent to N 0/4) (fixes issue #3)

  • fixed slice_complement to display correct colours (issue #2).

Version 0.4.1

  • fixed plot_hex to preserve order of colours (fix courtesy of https://github.com/sebastian-c)

Version 0.4

  • fixed plotting functions to work with new themeing system in ggplot2 0.9.2

Version 0.3

  • put lookup code data in the right place to avoid namespace problems.

Version 0.2

  • added a NAMESPACE and removed package dependencies - colorspace is now imported, and ggplot2 is only a suggestion - you don't need it if you're using munsell only for colour choice, not for visualising the space.

Reference manual

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

install.packages("munsell")

0.4.3 by Charlotte Wickham, 2 years ago


Browse source code at https://github.com/cran/munsell


Authors: Charlotte Wickham <cwickham@gmail.com>


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports colorspace, methods

Suggests ggplot2, testthat


Imported by bea.R, mafs, scales.

Depended on by soilprofile.

Suggested by RGraphics.


See at CRAN