What’s the best way to choose graph colors?
I have an issue I hope someone can help me with. I am generating RRDtool graphs (for Cacti monitoring templates for MySQL, which I’ll release soon) that have up to 11 different metrics on them. With that many lines or areas on a graph, it becomes very hard to pick colors that are easy to see and easy to distinguish from each other. What’s a good way to choose such colors? Is there a way to do it automatically — is there a formal method that will produce good results?
I know some color theory and I have read about how you can distinguish colors from each other (hue, value etc). But I am unsure the best way to choose this many colors. Trying by hand produces garish results or graphs that are just hard to read.
My first attempt to solve this with a program was to simply create a list of every possible completely saturated color in a 32-bit space — essentially, the “pure” colors around the rim of the color wheel — and divide it into the desired number of evenly spaced intervals. This produces pure colors, which is not ideal. They are hard to look at. Did I mention garish?
I can shuffle the order so that they’re not adjacent, but that only helps avoid a “rainbow effect” if I’m stacking areas of color on top of each other, like in the following image:
Ugh, rainbows (I chose those by hand, not with my program). Lines on a white background might be placed in any order, so shuffling doesn’t help with those graphs.
I modified my little script to let me vary the saturation and value. My thinking was that lines on a white background really shouldn’t be full-value, and when I’m drawing areas instead of lines, I should de-saturate them so they become more pleasing pastels. This doesn’t really help as much as I might have hoped for, either. Colors around 80% saturation and 60% value look pretty good, but they’re still ugly colors. And I can’t get over five colors without them starting to run together again. Here’s an example with only four colors that’s already hard to look at:
Part of the problem, I’m currently thinking, is that I’m varying only one dimension. I could be varying the saturation as well as the hue, for example. But that might be another rabbit hole that will waste more time.
Right now I’m thinking that I should ask for help, instead of continuing to work on this myself. So, any ideas are welcome!
By the way, beautiful colors would be nice… a lot of the colors I choose by hand are very pretty and I’m sure my impartial, evenly-distributing script will never choose them in a million years. Also, it’s actually a good thing when graphs each have their own color scheme (as long as it’s attractive) because it becomes easier to identify graphs without having to read the title. Just some extra food for thought.



Well, I can’t directly suggest any colors, but when I created a monitoring package for some application daemons, I just borrowed the colors used by a freely available monitoring package, Monitorix. It uses some pretty good looking color combinations.
James McNellis
23 Mar 08 at 12:54 am
11 data elements is a lot to have on a graph. 6 is the most I tend to go with. That said, some ways to cram a lot more details on the graph without killing the reader’s eyes:
- Multiply all the writes by -1 with a cdef so that you have a graph with reads on top, and writes on the bottom. Keep the colours the same
- Remember, you have three different line thicknesses to choose from.
- Use area/stack along with lines. For example, aggregate writes as a light coloured area with various components on top as a line. The -1 trick works well, too
- Does it need to be on the graph? Sometimes the data is better put as a gprint/comment on the bottom of the graph
- Play with scaling some values (not always appropriate) so that the lines are separated by whitespace.
For colours, I try to stick with the simple ones: red, green, blue, yellow, black
Sean
Sean
23 Mar 08 at 9:38 am
And use an utility to similate colourblindness. I am not colourblind myself, but I got customerfeedback from some of my customers that they where not able to see the difference between lines within the same graph.
Merlijn Tishauser
23 Mar 08 at 12:03 pm
Sean, I like your ideas a lot. Especially negating.
Xaprb
23 Mar 08 at 3:52 pm
I don’t think there’s any way to do this algorithmically – color is too subjective and tricky. I would suggest starting at one of the color palette warehouses such as colourlovers.com or kuler.adobe.com and finding a palette that you like.
Unfortunately, most of the palettes in these archives fall short of the number of colors that you need. But I think that if you found a nice palette of 6 colors without a lot of value variation, you could duplicate the colors in a lighter or darker value to create a sufficient number of colors.
Garth Snyder
23 Mar 08 at 4:50 pm
Haven’t used this tool for graphs, but in a lot of other situations where I’ve wanted a selection of good colors it’s served my purpose: http://www.colorschemer.com/online.html
Carsten Pedersen
23 Mar 08 at 6:58 pm
I think Carsten and Garth both hit is on the head. When I first read your blog a couple days ago, I thought about the last time I tried to pick colors to paint trim in our kitchen! We ended up using what I picked, and then redoing it all 6 months later ’cause it was so bad. So going with a swatch that you can get either online or at Lowes I think is the way to go.
Eric Pugh
28 Mar 08 at 8:16 pm
1) Use a designer for design work ;-)
2) Use Adobe Kuler for creating palettes, then expand your choices based one this palette
3) Focus on shades, not hues
4) Avoid primary colours, and over-saturation
5) Read up on Edvard Tufte ! (Tufte is God)
Kristian
16 Jul 08 at 4:35 am
Yes, the math-based approach didn’t work well. But I ripped some palettes off of colourlovers.com and that ended up working very well indeed!
Xaprb
16 Jul 08 at 7:49 am
Great! Colours can be difficult indeed, been working with them for half my life and they can still cause trouble! Designers end up ripping palettes of others too, sometimes…
For further investigation: some good examples here (check page 7 for graphs), and principles explained:
http://www.stonesc.com/pubs/Expert Color Choices.pdf
Another tool (put in a color with low saturation and start from there):
http://www.colorschemer.com/online.html?r=51&g=102&b=255&hex=666660
Kristian
17 Jul 08 at 3:31 am
Baron,
What was your final method of coloring your Cacti=templates charts? I’m now encountering the same question for mycheckpoint.
Shlomi Noach
18 Sep 10 at 9:18 am
(That is, I followed colourlovers and did not find schemes for charts – did you just use palettes?)
Shlomi Noach
18 Sep 10 at 9:19 am
Sorry for flooding this thread, but the following site makes wonders: http://colorschemedesigner.com/
Shlomi Noach
18 Sep 10 at 9:28 am
I go to colourlovers.com, choose a palette that I like, and use the colors from it. Try http://www.colourlovers.com/palettes/most-loved/all-time/meta
Xaprb
18 Sep 10 at 9:58 am