Two more points about crayon colors

If you want to use crayon colors in R but you don’t want to rely on my R/broman package, you can just grab the code. Copy the relevant lines from the R/brocolors.R file:

crayons = c("Almond"="#efdecd",
            "Antique Brass"="#cd9575",
            "Yellow Green"="#c5e384",
            "Yellow Orange"="#ffb653")

I spent a bit of time thinking about how best to sort the colors in a meaningful way, for the plot_crayons() function. But then decided to stop thinking and just do something brainless: measure distance between colors by RMS difference of the RGB values, and then use hierarchical clustering. Here’s the code from plot_crayons():

# get rgb 
colval <- t(col2rgb(crayons))

# hclust to order the colors
ord <- hclust(dist(colval))$order

It’s not perfect, but I think it worked remarkably well:

Crayon colors

Tags: , ,

8 Responses to “Two more points about crayon colors”

  1. Wei Zou Says:

    just curious, don’t you have a graduate student to work out these technical details for you?

  2. apwheele Says:

    Looks pretty good to me as well! Another way might be to cluster according to HSV values – but that still needs some more thought. Hue is perhaps best thought of as cyclical in that color space – so a non-lazy distance metric may be harder to come by.

  3. apwheele Says:

    Meh – maybe ignore that train. Just tried it using euclidean distance in HSV space – I like the rgb results better though. See

  4. Ken Butler Says:

    It does seem to make a good list of colours. I’m curious, though: why, if green is one of the primary colours, are there several episodes of green (the first, fifth and sixth columns), whereas the reds are basically all together, and the blues ditto?

  5. Shapes, colors, and pattern constants in SPSS charts | Andrew Wheeler Says:

    […] useful change for the colors would be sorting in a logical order. They are just currently in alphabetical. I am too lazy though to convert the colors to a […]

Comments are closed.