An interface for creating palettes from colorgorical.
colorgorical( n = 10, perceptualDifference = 0, nameDifference = 0, nameUniqueness = 0, pairPreference = 0, hueFilters = list(), lightnessRange = c("25", "85"), startPalette = list(), output = "HEX" )
n | Number of color values to return. |
---|---|
perceptualDifference | Value from 0 to 1. See details. |
nameDifference | Value from 0 to 1. See details. |
nameUniqueness | Value from 0 to 1. See details. |
pairPreference | Value from 0 to 1. See details. |
hueFilters | Must be given as an element of a list. See details. |
lightnessRange | See details. |
startPalette | A starting point for the color as a vector of 3 CIE Lab values. Must be given as an element of a list. See details. |
output | Character string. Output may be given as LAB, sRGB, or HEX values. If 'LAB' or 'sRGB', a matrix of those values where each row represents a color. If 'HEX', the default, a character vector of hex values is returned. |
A character vector of color values in hex form.
This function accesses the colorgorical website to create a color
palette. It requires two other packages to work: httr
and
jsonlite
, and if you want a hex value, colorspace
.
The following are relevant parts from the descriptions at the website.
Perceptual Distance: Increasing Perceptual Distance favors palette colors that are more easily discriminable to the human eye. To accurately model human color acuity, this is performed using CIEDE2000 in CIE Lab color space.
Name Difference: Increasing Name Difference favors palette colors that share few common names. This is similar to perceptual distance, but can lead to different results in certain areas of color space. This happens when there are many different names for perceptually close colors (e.g., red and pink are perceptually close but named differently). Colorgorical calculates this using Heer and Stone's Name Difference function, which is built on top of the XKCD color-name survey.
Pair Preference: Increasing Pair Preference favors palette colors that are, on average, predicted to be more aesthetically preferable together. Typically these colors are similar in hue, have different lightness, and are cooler colors (blues and greens). Pair Preference is based off of Schloss and Palmer's research on color preference.
Name Uniqueness: Increasing Name Uniqueness favors palette colors that are uniquely named. Some colors like red are readily named and are favored, whereas other colors are less obviously named and are ignored. Like, Name Difference, Name Uniqueness is based on Heer and Stone's color-name research.
Select hue filter: You can limit which colors are selected by either dragging over the wheel to select a hue range, or by entering the angles manually (e.g., select only reds). You can also make multiple selections after one another to select many different hue ranges (e.g., select both greens and purples).
Select lightness range: You can change whether Colorgorical samples lighter or darker colors.
Add starting colors: You can guarantee that certain colors are in your palette. Note, as near as I can tell, it is only guaranteed if you have already created a palette at the website and start with one of the generated colors. Otherwise, it appears to pick something close to the starting point(s) given the settings. See the example.
NOTE: Because JSON is being used behind the scenes, for hueFilters
and startPalette
, the values must be given as a list.
For example:
hueFilters = list(c(90, 180))
startPalette = list(c(59, 62, 70))
The R code is based on the gist by Kamil Slowikowski found here: link.
Original Python source code at GitHub.