colorgorical: Create a colorgorical palette

Description Usage Arguments Details Value References Examples

View source: R/colorgorical.R


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



Number of color values to return.


Value from 0 to 1. See details.


Value from 0 to 1. See details.


Value from 0 to 1. See details.


Value from 0 to 1. See details.


Must be given as an element of a list. See details.


See details.


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.


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.


This function accesses the colorgorical website to create a color palette. It requires two other packages to work: httr and jsonlite.

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 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.

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.


A character vector of color values in hex form.


The colorgorical website.

Original Python source code at GitHub.


## Not run: 
colorgorical(n=12, pairPreference = 1, startPalette = list(c(10, -60, 45)))

## End(Not run)

mclark--/lazerhawk documentation built on July 17, 2018, 3:11 a.m.