When it Comes to Dataviz, Color is Complicated: Part 1
While I've touched upon the use of color before, a fuller explanation has had to wait for this two-part series. This one, the first, covers basic color theory, while the seconds covers color in practice.
Join the DZone community and get the full member experience.Join For Free
in all the articles i've written here i've covered a fairly broad range of topics related to data visualization: the use of tick marks and labels , data density , the problems with dual-axis charts and much more. i've touched upon the use of color a few times but only in passing. that's because i think, while interesting, the topic can be quite confusing and that makes writing short articles difficult. in this two-part series i'll try to bring together previous advice on the use of color, cover why i think it's a complex topic, define some relevant jargon, and provide links to a few resources that i have found useful. in this part i cover why what we see might not be what we expect to see. in part 2 i'll look at picking suitable color palettes.
what color is that?
one morning in february 2015 i awoke and checked what was going on in the world via twitter. everyone was talking about a white and gold dress. or rather they were talking about what looked like to me like a white and gold dress. many felt the same as me but some strange people were claiming it was blue and black. it turns out those strange people were actually right. the viral phenomenon that was "the dress" showcased the peculiarities of our vision system.
colin ware describes, on page 69 of information visualization (third edition), how "[n]eurons processing visual information in the early stages of the retina and primary visual cortex do not behave like light meters; they act as change meters". one benefit of the complex way our visual system works is that we can usually detect a gray surface as being gray, a white surface as being white and a black surface as being black whether we're in bright sunlight or a dimly lit room and independently of the color of the illuminant. this is called "color constancy" and it shouldn't be too difficult to imagine how this could have been an evolutionary advantage in the past. information about the light source itself is usually much less important.
to achieve color constancy the brain has to make some educated guesses about the illuminant. sometimes it gets things wrong. this would appear to be at least part of the reason for the disagreement over the dress.
if you're creating a visual representation of some data it's rare you'll ever have to worry too much about the perceived colors of a dress. but it does still highlight the fact that sometimes we misinterpret color stimuli. take the simple image below:
if you've never seen this illusion before you may be surprised to learn that the small squares are the same color. you can check this using the eyedropper or color-picker tool of your favorite image editing program. if you're on a mac it's quicker to use osx's digitalcolor meter app.
this color contrast illusion can be significant for data visualization: if you're using the same color encoding on two different backgrounds you need to check whether they really look the same. remember the blocks of color in your key or legend too. if a chart background is, say, light gray then the background in the key should also be light gray and not white or black (we're not talking about natural illuminants here so don't expect your brain to fix it for you).
not everyone has perfect color vision
the color-sensitive cells of the retina are called cones and we (most of us) have three types — millions of each — making us "trichromats". the types are frequently referred to as red, green and blue, though it's more proper to use long (l), medium (m) and short (s), describing the wavelengths of peak sensitivity. even this is very much a relative designation: l cones are most sensitive to light at around 580 nanometers, m cones to light at around 540 nm and s cones to light at around 450 nm (ware, page 97). (there's no relation here with the designations for radio waves!)
color blindness, or color vision deficiency (cvd), in humans is the result of a lack of, or deficiency in, one type of cone cell. it can be acquired or inherited and the latter is fairly common in men (around one in 12 suffer). if it is l or m cones that are lacking the resulting condition is frequently described as red-green color blindness, while blue-yellow color blindness results from defective s cones. in reality, the effect is more nuanced than these common names would suggest and a number of tools have been developed to help trichromats without a cvd ensure their work is accessible to those who do suffer. my favorite is colororacle . it's a really simple app for windows, mac and (some) linux os's that sits in the notification area (system tray) or menubar. you click on its icon, select a form of color deficiency and it instantly (temporarily!) changes the colors on the screen to simulate the deficiency.
deuteranopia, the formal name for a problem with m cones, is the most common form of cvd. as i've previously mentioned , it's a good reason to avoid using only red and green color encoding in your visualizations. if you do want to use a "traffic light" color scheme then one option is to use a secondary encoding to reinforce the differences, for example a red circle and a green triangle (perhaps with an amber square).
Published at DZone with permission of Tim Brock, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.