Author: Kevin R. Coombes

# Color Names

#### Kevin R. Coombes

In this vignette, we describe various tools for assigning color names to the hexadecimal representations of RGB colors.

## Getting Started

As usual, we start by loading the package:

    library(Polychrome)

Next, we can look at one of the color palettes it provides.

    data(alphabet)

    swatch(alphabet)

As you can see, the `alphabet` palette has assigned names to colors that begin with different letters of the English alphabet. Since the `Polychrome` pacakge includes three differnt sets of (more or less) standard color names, we can see what they do for these colors:

    cn <- colorNames(alphabet) # from UNIX rgb.txt file
    cc <- isccNames(alphabet) # standards from the Inter-Society Color Council
    xk <- xkcdNames(alphabet) # from the  xkCd online color survey
    df <- data.frame(UNIX = cn, ISCC = cc, XKCD = xk)
    rownames(df) <- names(alphabet)
    df

    ##                        UNIX                  ISCC            XKCD
    ## amethyst             purple          Vivid_Violet electric_purple
    ## blue             dodgerblue  Strong_Purplish_Blue     dodger_blue
    ## caramel          goldenrod4     Light_Olive_Brown     muddy_brown
    ## damson              purple3          Vivid_Violet    bluey_purple
    ## ebony                gray34             Dark_Gray   charcoal_grey
    ## forest             seagreen           Vivid_Green  dark_sea_green
    ## green                 green Vivid_Yellowish_Green       hot_green
    ## honey           navajowhite           Pale_Yellow      pale_peach
    ## iron                 gray89        Purplish_White      light_grey
    ## jade           springgreen3 Vivid_Yellowish_Green  shamrock_green
    ## kingcrab            tomato3 Strong_Reddish_Orange    brick_orange
    ## lavender              plum1      Brilliant_Purple     baby_purple
    ## magenta             magenta          Vivid_Purple     pink/purple
    ## navy            dodgerblue4           Strong_Blue       dusk_blue
    ## orange       darkgoldenrod1   Vivid_Orange_Yellow   yellow_orange
    ## pink             lightpink1           Strong_Pink           blush
    ## quagmire    darkolivegreen3    Vivid_Yellow_Green       pea_green
    ## red              firebrick1             Vivid_Red             red
    ## sea              aquamarine       Brilliant_Green     bright_teal
    ## turquoise      lightskyblue            Vivid_Blue       neon_blue
    ## ultraviolet     darkmagenta  Vivid_Reddish_Purple    purpley_pink
    ## violet                plum3 Strong_Reddish_Purple      light_plum
    ## wine                maroon1    Vivid_Purplish_Red     bright_pink
    ## xanthin          violetred3    Vivid_Purplish_Red    deep_magenta
    ## yellow                 gold Vivid_Greenish_Yellow       dandelion
    ## zinnia             deeppink             Vivid_Red     strong_pink

Careful examination of this table shows that several ISCC names are duplicated:

    apply(df, 2, function(X) length(unique(X)))

    ## UNIX ISCC XKCD
    ##   26   22   26

    dupn <- df$ISCC[duplicated(df$ISCC)]
    tmp <- df[df$ISCC %in% dupn,]
    tmp[order(tmp[,2]),]

    ##                  UNIX                  ISCC            XKCD
    ## wine          maroon1    Vivid_Purplish_Red     bright_pink
    ## xanthin    violetred3    Vivid_Purplish_Red    deep_magenta
    ## red        firebrick1             Vivid_Red             red
    ## zinnia       deeppink             Vivid_Red     strong_pink
    ## amethyst       purple          Vivid_Violet electric_purple
    ## damson        purple3          Vivid_Violet    bluey_purple
    ## green           green Vivid_Yellowish_Green       hot_green
    ## jade     springgreen3 Vivid_Yellowish_Green  shamrock_green

## Scatter Plots

Our standard way to think about colors is in the L*u*v* color space model defined by the CIE. The next plot shows how the points in various “color name spaces” are distributed in the u-v subspace.

    data(xkcd)
    data(iscc)
    colMat <- col2rgb(colors())
    opar <- par(mfrow = c(2,2))
    unix <- rgb(red = colMat[1, ]/255, green = colMat[2, ]/255, blue = colMat[3, ]/255)
    uvscatter(alphabet, xlim = c(-80, 160), ylim =c (-130, 125))
    uvscatter(iscc$Hex, xlim = c(-80, 160), ylim =c (-130, 125), main = "ISCC")
    uvscatter(unix, xlim = c(-80, 160), ylim =c (-130, 125), main = "UNIX")
    uvscatter(xkcd$Hex, xlim = c(-80, 160), ylim =c (-130, 125), main = "XKCD")

    par(opar)

As you can see, the `alphabet` colors are widely dispersed across the color spectrum, making them somewhat easier to distinguish. The 247 standard colors from the ISCC are clumped twoard the middle of the space, making it harder to name colors out on the fringes. The UNIX rgb.txt color names consist of 697 names, but some of these are duplicate names for the same 502 distinct hexadecimal color representations. Even so, there are clear gaps in the color space that are not given distinct names. The results fo teh XKCD survey have a much denser coverage of more of the available color space.