munsell/ 0000755 0001762 0000144 00000000000 14602642732 011737 5 ustar ligges users munsell/NAMESPACE 0000644 0001762 0000144 00000001060 14602573556 013162 0 ustar ligges users # Generated by roxygen2: do not edit by hand
export(check_mnsl)
export(chroma_slice)
export(complement)
export(complement_slice)
export(darker)
export(desaturate)
export(fix_mnsl)
export(hue_slice)
export(hvc2mnsl)
export(in_gamut)
export(lighter)
export(mnsl)
export(mnsl2hex)
export(mnsl2hvc)
export(mnsl_hues)
export(pbgyr)
export(plot_closest)
export(plot_hex)
export(plot_mnsl)
export(rgb2mnsl)
export(rygbp)
export(saturate)
export(seq_mnsl)
export(text_colour)
export(value_slice)
import(colorspace)
importFrom(methods,as)
importFrom(stats,na.exclude)
munsell/LICENSE 0000644 0001762 0000144 00000000056 14602573556 012754 0 ustar ligges users YEAR: 2016
COPYRIGHT HOLDER: Charlotte Wickham munsell/README.md 0000644 0001762 0000144 00000010552 14602601246 013214 0 ustar ligges users
Downloads
[](https://github.com/cwickham/munsell/actions/workflows/R-CMD-check.yaml)
# 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.
`munsell` relies directly on the published tables in Newhall, Nickerson,
and Judd (1943) of CIE XYZ (Illuminant C) values for Munsell colours.
These tables were the result of colour matching studies on Munsell’s
color samples along with some smoothing and extrapolation with Munsell’s
goal of perceptually uniform spacing in mind.
Currently the `munsell` package only includes hue in steps of 2.5, value
in steps of 2 and chroma in steps of 1, corresponding directly to the
entries in Table 1 in Newhall, Nickerson, and Judd (1943). If you
require a more continuous mapping, see
[munsellinter](https://r-forge.r-project.org/projects/munsellinterpol/).
# Usage
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:
``` r
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:
``` r
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`:
``` r
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`.
``` r
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.
``` r
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.
``` r
complement_slice("5R")
```

# References
Newhall, Sidney M, Dorothy Nickerson, and Deane B Judd. 1943. “Final
Report of the OSA Subcommittee on the Spacing of the Munsell Colors.”
*JOSA* 33 (7): 385–411.
munsell/man/ 0000755 0001762 0000144 00000000000 14602577356 012523 5 ustar ligges users munsell/man/theme_munsell.Rd 0000644 0001762 0000144 00000000533 14602573556 015652 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.r
\name{theme_munsell}
\alias{theme_munsell}
\title{Default munsell plot theme}
\usage{
theme_munsell(bg.col = "white")
}
\arguments{
\item{bg.col}{takes colour to use as background colour}
}
\description{
Removes unnecessary clutter in plots
}
\keyword{internal}
munsell/man/darker.Rd 0000644 0001762 0000144 00000001100 14602573556 014250 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/alter.r
\name{darker}
\alias{darker}
\title{Make a munsell colour darker}
\usage{
darker(col, steps = 1)
}
\arguments{
\item{col}{character vector of Munsell colours}
\item{steps}{number of steps to take in decreasing value}
}
\value{
character vector of Munsell colours
}
\description{
Decreases the value of the Munsell colour by 1.
}
\examples{
darker("5PB 3/4")
cols <- c("5PB 3/4", "5Y 7/8")
p <- plot_mnsl(c(cols, darker(cols), darker(cols, 2)))
p + ggplot2::facet_wrap(~ names, ncol = 2)
}
munsell/man/plot_hex.Rd 0000644 0001762 0000144 00000000752 14602573556 014636 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.r
\name{plot_hex}
\alias{plot_hex}
\title{Plot hex colours}
\usage{
plot_hex(hex.colour, back.col = "white")
}
\arguments{
\item{hex.colour}{character vector specifying colours in hex form}
\item{back.col}{specification of background colour of display}
}
\value{
A ggplot object
}
\description{
Quick way to look at a set of hex colours.
}
\examples{
plot_hex("#000000")
plot_hex(c("#000000","#FFFFFF"))
}
munsell/man/value_slice.Rd 0000644 0001762 0000144 00000001037 14602573556 015304 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.r
\name{value_slice}
\alias{value_slice}
\title{Plot all colours with the same value}
\usage{
value_slice(value.name = 1:10, back.col = "white")
}
\arguments{
\item{value.name}{integer vector of the desired values.}
\item{back.col}{colour for the background}
}
\value{
ggplot object
}
\description{
Plots slices of the Munsell colour system where value is constant.
}
\examples{
value_slice(2)
value_slice(c(2, 4))
# all values
\dontrun{value_slice(1:10)}
}
munsell/man/in_gamut.Rd 0000644 0001762 0000144 00000001355 14602573556 014617 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/check.r
\name{in_gamut}
\alias{in_gamut}
\title{Checks if a Munsell colour is defined in RGB space}
\usage{
in_gamut(col, fix = FALSE)
}
\arguments{
\item{col}{a character vector representing Munsell colours.}
\item{fix}{passed on to \code{\link{fix_mnsl}}. Use \code{fix = TRUE} to
fix "bad" colours}
}
\value{
a character vector containing the input colours. If any colours
were outside the gamut they will be represented by NA.
}
\description{
Not all possible correctly formatted Munsell colours result in a colour
representable in RGB space. This function checks if the colour is
representable.
}
\examples{
in_gamut(c("5R 5/8","2.5R 9/28"))
}
\keyword{internal}
munsell/man/text_colour.Rd 0000644 0001762 0000144 00000000576 14602577356 015371 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.r
\name{text_colour}
\alias{text_colour}
\title{Get text colour}
\usage{
text_colour(cols)
}
\arguments{
\item{cols}{a character vector of munsell colours}
}
\value{
a vector of "black" or "white"
}
\description{
Get the appropriate text colour for writing on a munsell colour.
}
\keyword{internal}
munsell/man/mnsl.Rd 0000644 0001762 0000144 00000002155 14602573556 013764 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/convert.r
\name{mnsl}
\alias{mnsl}
\alias{mnsl2hex}
\title{Converts a Munsell colour to hex}
\usage{
mnsl(col, ...)
}
\arguments{
\item{col}{a character string representing a Munsell colour.}
\item{...}{passed on to \code{\link{in_gamut}}. Use \code{fix = TRUE} to
fix "bad" colours}
}
\value{
a character string specification of a hex colour
}
\description{
Take a character string representation of a Munsell colour and returns the
hex specification of that colour
}
\details{
Munsell colours are specified by hue, value and chroma. They
take a form like "5PB 5/10" where the first characters represent the
hue, followed by a space then the value and chroma separated by a "/". In
this package value should be an integer in 0:10 and chroma an even number
at most 24. Note that not all possible specifications result in
representable colours.
}
\examples{
mnsl2hex("5PB 5/10")
# use a munsell colour in a plot
plot.new()
rect(0, 0, 1 ,1 , col = mnsl("5R 5/10"))
}
\seealso{
\code{\link{check_mnsl}},\code{\link{in_gamut}}, \code{\link{hvc2mnsl}}
}
munsell/man/pbgyr.Rd 0000644 0001762 0000144 00000001050 14602573556 014127 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/alter.r
\name{pbgyr}
\alias{pbgyr}
\title{Change the hue of a munsell colour}
\usage{
pbgyr(col, steps = 1)
}
\arguments{
\item{col}{character vector of Munsell colours}
\item{steps}{number of hue steps to take}
}
\value{
character vector of Munsell colours
}
\description{
Moves the hue of a munsell colour in the direction purple->blue->green->yellow->red->purple
}
\examples{
my_red <- "2.5R 4/8"
pbgyr(my_red)
plot_mnsl(c(my_red, pbgyr(my_red, 2), pbgyr(my_red, 4)))
}
munsell/man/plot_mnsl.Rd 0000644 0001762 0000144 00000001470 14602573556 015021 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.r
\name{plot_mnsl}
\alias{plot_mnsl}
\title{Plot a munsell colour}
\usage{
plot_mnsl(cols, back.col = "white", ...)
}
\arguments{
\item{cols}{character vector specifying colours in Munsell form}
\item{back.col}{specification of background colour of display}
\item{...}{passed to \code{\link{check_mnsl}}. Add fix = TRUE to fix "bad" colours()}
}
\value{
A ggplot object
}
\description{
Takes munsell text specifications and plots colour squares of them.
}
\examples{
plot_mnsl("5R 5/6")
plot_mnsl("5R 5/6", back.col = "grey40")
p <- plot_mnsl(c("5R 6/6", "5Y 6/6", "5G 6/6", "5B 6/6", "5P 6/6"),
back.col = "grey40")
p
# returned object is a ggplot object so we can alter the layout
summary(p)
p + ggplot2::facet_wrap(~ num, nrow = 1)
}
munsell/man/rgb2mnsl.Rd 0000644 0001762 0000144 00000001267 14602573556 014544 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/convert.r
\name{rgb2mnsl}
\alias{rgb2mnsl}
\title{Converts an sRGB colour to Munsell}
\usage{
rgb2mnsl(R, G = NULL, B = NULL)
}
\arguments{
\item{R}{a numeric vector of red values or a 3 column matrix with the
proportions R, G, B in the columns.}
\item{G}{numeric vector of green values}
\item{B}{numeric vector of blue values}
}
\description{
Finds the closest Munsell colour (in LUV space) to the specified sRGB colour
}
\examples{
rgb2mnsl(0.1, 0.1, 0.3)
rgb2mnsl(matrix(c(.1, .2, .4, .5, .6, .8), ncol = 3))
plot_closest(matrix(c(.1, .2, .4, .5, .6, .8), ncol = 3))
}
\seealso{
\code{\link{plot_closest}}
}
munsell/man/desaturate.Rd 0000644 0001762 0000144 00000001200 14602573556 015142 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/alter.r
\name{desaturate}
\alias{desaturate}
\title{Make a munsell colour less saturated}
\usage{
desaturate(col, steps = 1)
}
\arguments{
\item{col}{character vector of Munsell colours}
\item{steps}{number of steps to take in decreasing chroma}
}
\value{
character vector of Munsell colours
}
\description{
Decreases the chroma of the Munsell colour by one step steps (multiples of 2).
}
\examples{
desaturate("5PB 2/4")
cols <- c("5PB 2/6", "5Y 7/8")
p <- plot_mnsl(c(cols, desaturate(cols), desaturate(cols, 2)))
p + ggplot2::facet_wrap(~ names, ncol = 2)
}
munsell/man/seq_mnsl.Rd 0000644 0001762 0000144 00000001511 14602573556 014627 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/alter.r
\name{seq_mnsl}
\alias{seq_mnsl}
\title{Generate a sequence of Munsell colours}
\usage{
seq_mnsl(from, to, n, fix = FALSE)
}
\arguments{
\item{from}{character string of first Munsell colour}
\item{to}{character string of last Munsell colour}
\item{n}{number of colours in sequence}
\item{fix}{Should colours outside of the gamut be fixed?
Passed on to \code{\link{fix_mnsl}}}
}
\value{
character vector of Munsell colours
}
\description{
Generates a sequence of Munsell colours. The sequence is generated by
finding the closest munsell colours to a equidistant sequence of colours in #' LUV space.
}
\examples{
seq_mnsl("5R 2/4", "5R 5/16", 4)
plot_mnsl(seq_mnsl("5R 2/4", "5R 5/16", 4))
plot_mnsl(seq_mnsl("5R 5/6",
complement("5R 5/6"), 5))
}
munsell/man/rygbp.Rd 0000644 0001762 0000144 00000001044 14602573556 014132 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/alter.r
\name{rygbp}
\alias{rygbp}
\title{Change the hue of a munsell colour}
\usage{
rygbp(col, steps = 1)
}
\arguments{
\item{col}{character vector of Munsell colours}
\item{steps}{number of hue steps to take}
}
\value{
character vector of Munsell colours
}
\description{
Moves the hue of a munsell colour in the direction red->yellow->green->blue->purple->red
}
\examples{
my_red <- "10R 4/8"
rygbp(my_red)
plot_mnsl(c(my_red, rygbp(my_red, 2), rygbp(my_red, 4)))
}
munsell/man/mnsl_hues.Rd 0000644 0001762 0000144 00000000554 14602573556 015011 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/check.r
\name{mnsl_hues}
\alias{mnsl_hues}
\title{Munsell hues}
\usage{
mnsl_hues()
}
\value{
a character vector containing the hue values.
}
\description{
Returns a character vector of the Munsell hues in hue order starting at 2.5R and excluding grey ("N").
}
\examples{
mnsl_hues()
}
munsell/man/mnsl2hvc.Rd 0000644 0001762 0000144 00000002120 14602573556 014537 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/convert.r
\name{mnsl2hvc}
\alias{mnsl2hvc}
\title{Converts a Munsell colour to a hue, chroma and value triplet}
\usage{
mnsl2hvc(col, ...)
}
\arguments{
\item{col}{a character vector of Munsell colours}
\item{...}{passed on to \code{\link{check_mnsl}}. Use \code{fix = TRUE} to
fix "bad" colours}
}
\value{
a data frame with named columns hue, value and chroma containing the hue,
value and chroma levels.
}
\description{
Takes a text specification of a Munsell colour and returns
the hue, chroma and value triplet.
}
\details{
Munsell colours are specified by hue, value and chroma. They
take a form like "5PB 5/10" where the first characters represent the
hue, followed by a space then the value and chroma separated by a "/". In
this package value should be an integer in 0:10 and chroma an even number
at most 24. Note that not all possible specifications result in
representable colours.
}
\examples{
mnsl2hvc("5PB 5/10")
hvc2mnsl(mnsl2hvc("5PB 5/10"))
}
\seealso{
\code{\link{check_mnsl}}, \code{\link{hvc2mnsl}}
}
munsell/man/complement_slice.Rd 0000644 0001762 0000144 00000001026 14602573556 016331 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.r
\name{complement_slice}
\alias{complement_slice}
\title{A vertical slice through the Munsell space}
\usage{
complement_slice(hue.name, back.col = "white")
}
\arguments{
\item{hue.name}{character string of the desired hue.}
\item{back.col}{colour for the background}
}
\value{
ggplot object
}
\description{
Plot a hue and its complement at all values and chromas
}
\examples{
complement_slice("5PB")
complement_slice("5R")
complement_slice("10G")
}
munsell/man/figures/ 0000755 0001762 0000144 00000000000 14602601245 014150 5 ustar ligges users munsell/man/figures/README-palette-1.png 0000644 0001762 0000144 00000032352 14602601245 017412 0 ustar ligges users PNG
IHDR iCCPkCGColorSpaceGenericRGB 8U]hU>+$Ԧ5lRфem,lAݝi&3i)>A['!j-P(G 3k~s,[%,-:t}
}-+*&¿ gPG݅ج8"e Ų]A b ;l õ Wϙ2_E,(ۈ#Zsێ<5)"E6N#ӽEkۃO0}*rUt.iei # ]r
>cU{t7+ԙg߃xu