Title: | Utilities for Using Munsell Colours |
---|---|
Description: | 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. |
Authors: | Charlotte Wickham <[email protected]> |
Maintainer: | Charlotte Wickham <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.5.1.9000 |
Built: | 2024-10-29 03:00:44 UTC |
Source: | https://github.com/cwickham/munsell |
Plots slices of the Munsell colour system where chroma is constant.
chroma_slice(chroma.name = seq(0, 26, by = 2), back.col = "white")
chroma_slice(chroma.name = seq(0, 26, by = 2), back.col = "white")
chroma.name |
integer vector of the desired values. |
back.col |
colour for the background |
ggplot object
chroma_slice(2) chroma_slice(18) # Maybe want to delete text and add axis instead p <- chroma_slice(18) p$layers[[2]] <- NULL # remove text layer p + ggplot2::theme(axis.text = ggplot2::element_text(), axis.text.x = ggplot2::element_text(angle = 90, hjust = 1)) # all values ## Not run: chroma_slice(seq(0, 38, by = 2))
chroma_slice(2) chroma_slice(18) # Maybe want to delete text and add axis instead p <- chroma_slice(18) p$layers[[2]] <- NULL # remove text layer p + ggplot2::theme(axis.text = ggplot2::element_text(), axis.text.x = ggplot2::element_text(angle = 90, hjust = 1)) # all values ## Not run: chroma_slice(seq(0, 38, by = 2))
Finds the munsell colour with the same chroma and value but on the opposite side of the hue circle. The complement is not defined for greys (hue == "N"), and the function returns the grey untransformed.
complement(col, ...)
complement(col, ...)
col |
character vector of Munsell colours |
... |
deprecated |
character vector of Munsell colours
complement("5PB 2/4") cols <- c("5PB 2/4", "5Y 7/8") plot_mnsl(c(cols, complement(cols)))
complement("5PB 2/4") cols <- c("5PB 2/4", "5Y 7/8") plot_mnsl(c(cols, complement(cols)))
Plot a hue and its complement at all values and chromas
complement_slice(hue.name, back.col = "white")
complement_slice(hue.name, back.col = "white")
hue.name |
character string of the desired hue. |
back.col |
colour for the background |
ggplot object
complement_slice("5PB") complement_slice("5R") complement_slice("10G")
complement_slice("5PB") complement_slice("5R") complement_slice("10G")
Decreases the value of the Munsell colour by 1.
darker(col, steps = 1)
darker(col, steps = 1)
col |
character vector of Munsell colours |
steps |
number of steps to take in decreasing value |
character vector of Munsell colours
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)
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)
Decreases the chroma of the Munsell colour by one step steps (multiples of 2).
desaturate(col, steps = 1)
desaturate(col, steps = 1)
col |
character vector of Munsell colours |
steps |
number of steps to take in decreasing chroma |
character vector of Munsell colours
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)
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)
Plots slices of the Munsell colour system where hue is constant.
hue_slice(hue.name = "all", back.col = "white")
hue_slice(hue.name = "all", back.col = "white")
hue.name |
character vector of the desired hues. Or "all" for all hues. |
back.col |
colour for the background |
ggplot object
hue_slice("5R") hue_slice(c("5R", "5P")) ## Not run: hue_slice("all")
hue_slice("5R") hue_slice(c("5R", "5P")) ## Not run: hue_slice("all")
Takes separate specifications of hue, value and chroma and returns the text specification of that colour.
hvc2mnsl(hue, value = NULL, chroma = NULL, ...)
hvc2mnsl(hue, value = NULL, chroma = NULL, ...)
hue |
a character vector of Munsell hues, or a 3 column data frame containing the hue value and chroma levels |
value |
a numeric vector of values |
chroma |
a numeric vector of chromas |
... |
passed on to |
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. Regular recycling rules apply.
a character string specification of a hex colour
hvc2mnsl("5PB", 5, 10) # All values of 5PB with chroma 10 hvc2mnsl("5PB", 1:9, 10) # note some are undefined plot_mnsl(hvc2mnsl("5PB", 1:9, 10))
hvc2mnsl("5PB", 5, 10) # All values of 5PB with chroma 10 hvc2mnsl("5PB", 1:9, 10) # note some are undefined plot_mnsl(hvc2mnsl("5PB", 1:9, 10))
Increases the value of the Munsell colour.
lighter(col, steps = 1)
lighter(col, steps = 1)
col |
character vector of Munsell colours |
steps |
number of steps to take in increasing value |
character vector of Munsell colours
lighter("5PB 2/4") cols <- c("5PB 2/4", "5Y 6/8") p <- plot_mnsl(c(cols, lighter(cols), lighter(cols, 2))) p + ggplot2::facet_wrap(~ names, ncol = 2) # lighter and darker are usually reversible lighter(darker("5PB 2/4")) # unless you try to pass though white or black lighter(darker("5PB 1/4"))
lighter("5PB 2/4") cols <- c("5PB 2/4", "5Y 6/8") p <- plot_mnsl(c(cols, lighter(cols), lighter(cols, 2))) p + ggplot2::facet_wrap(~ names, ncol = 2) # lighter and darker are usually reversible lighter(darker("5PB 2/4")) # unless you try to pass though white or black lighter(darker("5PB 1/4"))
Take a character string representation of a Munsell colour and returns the hex specification of that colour
mnsl(col, ...)
mnsl(col, ...)
col |
a character string representing a Munsell colour. |
... |
passed on to |
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.
a character string specification of a hex colour
mnsl2hex("5PB 5/10") # use a munsell colour in a plot plot.new() rect(0, 0, 1 ,1 , col = mnsl("5R 5/10"))
mnsl2hex("5PB 5/10") # use a munsell colour in a plot plot.new() rect(0, 0, 1 ,1 , col = mnsl("5R 5/10"))
Returns a character vector of the Munsell hues in hue order starting at 2.5R and excluding grey ("N").
mnsl_hues()
mnsl_hues()
a character vector containing the hue values.
mnsl_hues()
mnsl_hues()
Takes a text specification of a Munsell colour and returns the hue, chroma and value triplet.
mnsl2hvc(col, ...)
mnsl2hvc(col, ...)
col |
a character vector of Munsell colours |
... |
passed on to |
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.
a data frame with named columns hue, value and chroma containing the hue, value and chroma levels.
mnsl2hvc("5PB 5/10") hvc2mnsl(mnsl2hvc("5PB 5/10"))
mnsl2hvc("5PB 5/10") hvc2mnsl(mnsl2hvc("5PB 5/10"))
Moves the hue of a munsell colour in the direction purple->blue->green->yellow->red->purple
pbgyr(col, steps = 1)
pbgyr(col, steps = 1)
col |
character vector of Munsell colours |
steps |
number of hue steps to take |
character vector of Munsell colours
my_red <- "2.5R 4/8" pbgyr(my_red) plot_mnsl(c(my_red, pbgyr(my_red, 2), pbgyr(my_red, 4)))
my_red <- "2.5R 4/8" pbgyr(my_red) plot_mnsl(c(my_red, pbgyr(my_red, 2), pbgyr(my_red, 4)))
Take an sRGB colour and plots it along with the closest Munsell colour (using rgb2mnsl
to find it)
plot_closest(R, G = NULL, B = NULL, back.col = "white")
plot_closest(R, G = NULL, B = NULL, back.col = "white")
R |
a numeric vector of red values or a 3 column matrix with the proportions R, G, B in the columns. |
G |
numeric vector of green values |
B |
numeric vector of blue values |
back.col |
colour for the background |
ggplot object
plot_closest(0.1, 0.1, 0.3) plot_closest(matrix(c(.1, .2, .4, .5, .6, .8), ncol = 3))
plot_closest(0.1, 0.1, 0.3) plot_closest(matrix(c(.1, .2, .4, .5, .6, .8), ncol = 3))
Quick way to look at a set of hex colours.
plot_hex(hex.colour, back.col = "white")
plot_hex(hex.colour, back.col = "white")
hex.colour |
character vector specifying colours in hex form |
back.col |
specification of background colour of display |
A ggplot object
plot_hex("#000000") plot_hex(c("#000000","#FFFFFF"))
plot_hex("#000000") plot_hex(c("#000000","#FFFFFF"))
Takes munsell text specifications and plots colour squares of them.
plot_mnsl(cols, back.col = "white", ...)
plot_mnsl(cols, back.col = "white", ...)
cols |
character vector specifying colours in Munsell form |
back.col |
specification of background colour of display |
... |
passed to |
A ggplot object
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)
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)
Finds the closest Munsell colour (in LUV space) to the specified sRGB colour
rgb2mnsl(R, G = NULL, B = NULL)
rgb2mnsl(R, G = NULL, B = NULL)
R |
a numeric vector of red values or a 3 column matrix with the proportions R, G, B in the columns. |
G |
numeric vector of green values |
B |
numeric vector of blue values |
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))
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))
Moves the hue of a munsell colour in the direction red->yellow->green->blue->purple->red
rygbp(col, steps = 1)
rygbp(col, steps = 1)
col |
character vector of Munsell colours |
steps |
number of hue steps to take |
character vector of Munsell colours
my_red <- "10R 4/8" rygbp(my_red) plot_mnsl(c(my_red, rygbp(my_red, 2), rygbp(my_red, 4)))
my_red <- "10R 4/8" rygbp(my_red) plot_mnsl(c(my_red, rygbp(my_red, 2), rygbp(my_red, 4)))
Increases the chroma of the Munsell colour by step steps (multiples of 2).
saturate(col, steps = 1)
saturate(col, steps = 1)
col |
character vector of Munsell colours |
steps |
number of steps to take in increasing chroma |
character vector of Munsell colours
saturate("5PB 2/4") cols <- c("5PB 2/2", "5Y 7/6") p <- plot_mnsl(c(cols, saturate(cols), saturate(cols, 2))) p + ggplot2::facet_wrap(~ names, ncol = 2)
saturate("5PB 2/4") cols <- c("5PB 2/2", "5Y 7/6") p <- plot_mnsl(c(cols, saturate(cols), saturate(cols, 2))) p + ggplot2::facet_wrap(~ names, ncol = 2)
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.
seq_mnsl(from, to, n, fix = FALSE)
seq_mnsl(from, to, n, fix = FALSE)
from |
character string of first Munsell colour |
to |
character string of last Munsell colour |
n |
number of colours in sequence |
fix |
Should colours outside of the gamut be fixed?
Passed on to |
character vector of Munsell colours
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))
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))
Plots slices of the Munsell colour system where value is constant.
value_slice(value.name = 1:10, back.col = "white")
value_slice(value.name = 1:10, back.col = "white")
value.name |
integer vector of the desired values. |
back.col |
colour for the background |
ggplot object
value_slice(2) value_slice(c(2, 4)) # all values ## Not run: value_slice(1:10)
value_slice(2) value_slice(c(2, 4)) # all values ## Not run: value_slice(1:10)