munsell v0.5.0

0

Monthly downloads

0th

Percentile

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.

Readme

munsell

The munsell package provides easy access to, and manipulation of, the Munsell colours. The munsell package provides a mapping between Munsell’s original notation (e.g. “5R 5/10”) and hexadecimal 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 perceptual 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 relevant 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")

Color specification

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")
#> [1] "#C65858"

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

Colour manipulation

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)

Colour space exploration

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

Functions in munsell

Name Description
mnsl2hvc Converts a Munsell colour to a hue, chroma and value triplet
saturate Make a munsell colour more saturated
mnsl_hues Munsell hues
seq_mnsl Generate a sequence of Munsell colours
mnsl Converts a Munsell colour to hex
text_colour Get text colour
rgb2mnsl Converts an sRGB colour to Munsell
theme_munsell Default munsell plot theme
value_slice Plot all colours with the same value
hue_slice Plot all colours with the same hue
hvc2mnsl Converts a hue, chroma and value to a Munsell colour
desaturate Make a munsell colour less saturated
munsell Munsell colour system.
chroma_slice Plot all colours with the same chroma
lighter Make a munsell colour lighter
in_gamut Checks if a Munsell colour is defined in RGB space
darker Make a munsell colour darker
plot_mnsl Plot a munsell colour
check_mnsl Checks for valid Munsell colours
complement Find the complement of a munsell colour
fix_mnsl Fix an undefined Munsell colour
complement_slice A vertical slice through the Munsell space
plot_closest Plot closest Munsell colour to an sRGB colour
pbgyr Change the hue of a munsell colour
plot_hex Plot hex colours
rygbp Change the hue of a munsell colour
No Results!

Last month downloads

Details

Type Package
License MIT + file LICENSE
URL https://cran.r-project.org/package=munsell, https://github.com/cwickham/munsell/
RoxygenNote 6.0.1
NeedsCompilation no
Packaged 2018-06-11 23:15:15 UTC; wickhamc
Repository CRAN
Date/Publication 2018-06-12 04:29:06 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/munsell)](http://www.rdocumentation.org/packages/munsell)