Martin Krzywinski / Genome Sciences Center / Martin Krzywinski / Genome Sciences Center / - contact me Martin Krzywinski / Genome Sciences Center / on Twitter Martin Krzywinski / Genome Sciences Center / - Lumondo Photography Martin Krzywinski / Genome Sciences Center / - Pi Art Martin Krzywinski / Genome Sciences Center / - Hilbertonians - Creatures on the Hilbert Curve
Thoughts rearrange, familiar now strange.Holly Golightly & The Greenhornes break flowersmore quotes

color: fun

EMBO Practical Course: Bioinformatics and Genome Analysis, 5–17 June 2017.

visualization + design

Brewer Palettes

Brewer Palettes at a Glance

Martin Krzywinski @MKrzywinski
All the Brewer palettes: qualitative, sequential and diverging. For each palette (e.g. spectral) the source colors are shown as well as all its n-color subsets. (zoom)

Presentation About Color and Brewer Palettes

If you're new to Brewer palettes, or color, catch up with this presentation. Color palettes matter - Brewer palettes and perceptual uniformity - Martin Krzywinski


I maintain a comprehensive database of named colors (3,116 colors), compiled from a variety of color name lists.

Visualization and Perception

Why Should Engineers and Scientists Be Worried About Color? by Bernice E. Rogowitz and Lloyd A. Treinish (IBM Thomas J. Watson Research Center, Yorktown Heights, NY).

Perception in Visualization by Christopher G. Healey (Department of Computer Science, North Carolina State University)

LAB and LCH gradient picker

Martin Krzywinski @MKrzywinski
Interactively create LAB and LCH color gradients interpolated across any number of colors.

Lch and Lab colour and gradient picker is a great tool by David Johnstone. It's a great way to generate color ramps—go ahead, go crazy!—and compare how the ramps look in different color spaces. Shame on you, HSV!

PaletteView — create continuous Brewer palettes

PaletteView is an exceptional tool by Magnaview to create continuous Brewer palettes. This tool is described in [1] and operationalizes Cyntha Brewer's color selection method into an algorithm that selects customizable color palettes from LCH space.

[1] Wijffelaars M, Vliegen R, Van Wijk JJ et al. 2008 Generating Color Palettes using Intuitive Parameters Computer Graphics Forum 27:743-750.

Brewer Palette Adobe Swatch Files

You can import Brewer palettes into Adobe applications such as Illustrator, Photoshop and InDesign using either the .ase or .ai swatch files.


Brewer palette ase swatch file for Adobe Illustrator Brewer palette ai swatch file for Adobe Illustrator Brewer palette pdf color file Brewer palette txt color file


In Illustrator, load the swatches from the swatch window menu. The swatch window can be accessed using Window > Swatches.

Select Open swatch library

then choose Other library...

and load either the .ase or .ai file — both contain the same content.

Brewer palettes are color combinations selected for their special properties for use in data visualization and information design.

The challenge

Selecting effective colors for bar plots, pie charts, and heat maps is made more difficult by the fact that the way we select color in software does not reflect how we perceive the color.

There are many examples of poor color combinations in published figures. For example, if categories are encoded with a combination of bright and dark colors, the bright colors will dominate the reader's attention. On the other hand, if two colors appear similar, the reader will instinctively perceive them as belonging to a group and infer that the underlying variables are related.

Colors with poor contrast (colors with similar perceived brightness) or simultaneous contrast (pure colors) also interfere with interpreting figures.

Selecting Colors in RGB and HSV

Most people select colors using RGB sliders, which is just about the worst way to pick a color! Consider the fact that when we look at a color, we cannot easily decompose it into its red, green and blue components. This limits usefulness of RGB for color selection.

HSV is a better color space, which defines a color based on hue, saturation and value. These are three properties that we intuitively assess when we see a color. We think of a "dark rich blue" and "light faded red", making HSV a reasonably useful model for color selection. Unfortunately, HSV has a nagging problem — although it is based on intuitive parameters, it is not perceptually uniform.

Perceptual Uniformity

A color space that is perceptually uniform defines colors based on how we perceive them. Distances between colors in the space are proportional to their perceived difference.

Above, we saw that HSV was not perceptually uniform. Moving the hue slider by 60 can have a small or large effect on a color, depending on where the slider is positioned.

Consider the following example. You have a chart that uses two colors, and orange and green. Both were chosen with S=V=100%. You now need to select a second color for each that is brighter. You cannot directly use HSV because both orange and green colors are already at full value. How do you intuitively increase brightness?

The reason why you cannot in do this in HSV is because V does not directly correspond to the color's perceived brightness. You are stuck fiddling with the saturation and value to try to select a brighter pairing.

What would be useful here is a color space which uses the intuitive parameters of HSV, but is perceptually based. In other words, instead of value, the space would define a color based on its perceived brightness. Luckily, this space exists — LCH, which defines color based on its luminance (perceived brightness), chroma (purity) and hue. Unfortunately, design and presentation software do not have LCH sliders and we cannot easily take advantage of this color space.

This is where the Brewer palettes come in.

Brewer Palettes

Brewer palettes were selected for their perceptual properties. These palettes were created by Cynthia Brewer for the purpose in cartography, but have found use in other fields.

Types of Brewer Palettes

There are three types of Brewer palettes

  • qualitative — colors do not have a perceived order
  • sequential — colors have a perceived order and perceived difference between successive colors is uniform
  • diverging — two back-to-back sequential palettes starting from a common color

Swatches of Brewer Palettes

I have prepared Brewer palette swatches in .ase or .ai format. For programming, use the plain-text version.

The image below (zoom) shows all the Brewer palettes.

Brewer palette colors - all swatches

Uses of Brewer Palettes

Qualitative palettes are excellent for bar plots and pie charts, where colors correspond to categories.

Grayscale Brewer palettes are available and are perfect for achieving good tone separation in black-and-white figures.

Sequential and diverging palettes are useful for heatmaps.

Brewer Palettes and Color Blindness

Some Brewer palettes are safe for color blindness — the pink-yellow-green (piyg) is one. For others, see colorbrewer.

I have designed 15-color palettes for color blindess for each of the three common types of color blindness.


news + thoughts

Tabular Data

Tue 11-04-2017
Tabulating the number of objects in categories of interest dates back to the earliest records of commerce and population censuses.

After 30 columns, this is our first one without a single figure. Sometimes a table is all you need.

In this column, we discuss nominal categorical data, in which data points are assigned to categories in which there is no implied order. We introduce one-way and two-way tables and the `\chi^2` and Fisher's exact tests.

Altman, N. & Krzywinski, M. (2017) Points of Significance: Tabular data. Nature Methods 14:329–330.

...more about the Points of Significance column

Happy 2017 `\pi` Day—Star Charts, Creatures Once Living and a Poem

Tue 14-03-2017

on a brim of echo,

capsized chamber
drawn into our constellation, and cooling.
—Paolo Marcazzan

Celebrate `\pi` Day (March 14th) with star chart of the digits. The charts draw 40,000 stars generated from the first 12 million digits.

Martin Krzywinski @MKrzywinski
12,000,000 digits of `\pi` interpreted as a star catalogue. (details)

The 80 constellations are extinct animals and plants. Here you'll find old friends and new stories. Read about how Desmodus is always trying to escape or how Megalodon terrorizes the poor Tecopa! Most constellations have a story.

Martin Krzywinski @MKrzywinski
Find friends and stories among the 80 constellations of extinct animals and plants. Oh look, a Dodo guardings his eggs! (details)

This year I collaborate with Paolo Marcazzan, a Canadian poet, who contributes a poem, Of Black Body, about space and things we might find and lose there.

Check out art from previous years: 2013 `\pi` Day and 2014 `\pi` Day, 2015 `\pi` Day and and 2016 `\pi` Day.

Data in New Dimensions: convergence of art, genomics and bioinformatics

Tue 07-03-2017

Art is science in love.
— E.F. Weisslitz

A behind-the-scenes look at the making of our stereoscopic images which were at display at the AGBT 2017 Conference in February. The art is a creative collaboration with Becton Dickinson and The Linus Group.

Its creation began with the concept of differences and my writeup of the creative and design process focuses on storytelling and how concept of differences is incorporated into the art.

Oh, and this might be a good time to pick up some red-blue 3D glasses.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski
A stereoscopic image and its interpretive panel of single-cell transcriptomes of blood cells: diseased versus healthy control.

Interpreting P values

Thu 02-03-2017
A P value measures a sample’s compatibility with a hypothesis, not the truth of the hypothesis.

This month we continue our discussion about `P` values and focus on the fact that `P` value is a probability statement about the observed sample in the context of a hypothesis, not about the hypothesis being tested.

Martin Krzywinski @MKrzywinski
Nature Methods Points of Significance column: Interpreting P values. (read)

Given that we are always interested in making inferences about hypotheses, we discuss how `P` values can be used to do this by way of the Benjamin-Berger bound, `\bar{B}` on the Bayes factor, `B`.

Heuristics such as these are valuable in helping to interpret `P` values, though we stress that `P` values vary from sample to sample and hence many sources of evidence need to be examined before drawing scientific conclusions.

Altman, N. & Krzywinski, M. (2017) Points of Significance: Interpreting P values. Nature Methods 14:213–214.

Background reading

Krzywinski, M. & Altman, N. (2017) Points of significance: P values and the search for significance. Nature Methods 14:3–4.

Krzywinski, M. & Altman, N. (2013) Points of significance: Significance, P values and t–tests. Nature Methods 10:1041–1042.

...more about the Points of Significance column