Let’s talk colormaps.

May 7, 2011 at 2:04 pm (powerfully stupid graphics)

Picture 17.png

T. Lennert and J. Martinez-Trujillo. Strength of response suppression to distracter stimuli determines
attentional-filtering performance in primate prefrontal neurons. Neuron, 70(1):141–52, Apr 2011. [pubmed]

[for less ranty, try here.] [or more recently here]

Dear everyone who uses colormaps: The ‘jet’ colormap, the default colormap in MATLAB, is a perceptual disaster. STOP USING THAT SHIT. I mean, just what is happening in the lower right sector of these plots?

Okay, more background. The scale is a raster of a modulation index (area under ROC, to be particular) for a group of neurons, plotted over the time from stimulus onset. The big salient feature of each plot is a yellow band. You see the yellow band because each raster plot sorts its neurons according to the “latency,” that is, the earliest time that the modulation passed some arbitrary threshold. Because that arbitrary threshold coincides with yellow, the highest-luminance value on the colormap, effectively the authors have chosen a computational and graphical procedure that says “Hey, sort my data that it makes a nice yellow stripe down the middle, NO MATTER WHAT THE DATA ACTUALLY CONTAINS.”

And what is happening to the right of that stripe? Well, because your spatial resolution for chroma differences (and especially for blue) is much worse than that for luminance differences (which is why sane colormaps, that are not “jet”, always have a monotonic luminance component), you have to get your nose right up to the screen to decide that under the stripe is a pretty good mixup of blue and red and yellow — all over the scale. In other words, some of these cells are well modulated past where they pass the arbitrary threshold, but a lot of cells stop being modulated at all after they dinged the threshold. Which is conveniently difficult to discern due to the colormap — and kind of raises the question of how reasonable that threshold setting is, or the cell inclusion criteria are.

We’ll just note in passing that the sorting is done separately for EACH subplot, so that row-by-row comparisons of the cells can’t be done, and the “neuron number” scale on the left is pretty much meaningless. Which also, by the way, fully undermines the claim that modulation for larger ordinal differences(*) happens faster.

I hope you noticed after you got close up to the screen, that the dark red and dark blue values are a lot harder to distinguish than, say, the yellow-to-cyan colors that makes up the middle of the scale. You know, we should be easily able to see when things are at opposite ends of the scale, right? I mean, if we’re plotting our data, I mean.

What kind of insane colormap has the property that values spanning the extreme ends of the scale stand out less, and can’t be distinguished as easily as values in the noisy middle? Why, it’s MATLAB’s default colormap, of course!

You know, ggplot uses a much better preset for its color maps, as well as better alternatives. Just sayin’.

(*) You want to know the ironic punchline? This catastrophe is figure 4 of a paper ABOUT NEURAL PROCESSING OF ORDINAL COLOR SCALES. Seriously!

I’m not sure whether this belongs on the ranting-about-neuroscience blog, or the ranting-about-MATLAB blog. so it goes on both places.

About these ads


  1. Graham said,

    To be fair to Matlab, you can turn off automatic color scaling if you want the two subplots to have equal color scales.

    What would be a more reasonable default? B/W? A colormap with a single hue?

    • crowding said,

      The paper describes the subplots having equal scales, so that’s not the problem.

      Of the defaults available in MATLAB, any of the single hue maps are unproblematic, and if you want a multiple-hue map for the sake of more jnds, “hot” isn’t completely stupid.

  2. Tim Tam said,

    Just want to say that I’m a huge fan of this blog… I will be happy when only when MATLAB is forced into bankruptcy because noone will buy their shitty software… too bad every brain lab in the country is running thier crap even with all the free stuff available

  3. Des said,

    The problem with the plot you’re showing is not a flaw of the colormap, but the person using it to display their data…. It’s a total PEBKAC.

    Jet’s awesome. Stop hating, and email the authors of that paper instead.

    • crowding said,

      The reason it was used here is because it is the default, which is a problem with MATLAB. There are a whole lot of PEBKAC, and a whole lot of those K’s and C’s live at The Mathworks, Inc.

      But I’ll bite. Point to one (one!) data display that jet is a good default choice for, as opposed to some other generic default. Perhaps you can explain why jet works well for that data, and in particular why it works better than hot, or gray, or 99 of the colormaps in the post going up tomorrow.

      • Martijn said,

        Every case where abs(x) is relevant for the value, but you still want to be able to distinguish -x from x. Typical example: the difference between two images. The most important information is where the two images are different (i.e. the (a-b) != 0), the second most relevant is the size of the change (i.e. abs(a-b)), the third is in what direction (a > b?).

        This is not to say that jet is the best color map for that case, but it is an example of where hot and grey certainly are /not/ a good choice.

      • crowding said,

        Yes, that’s what the IBM datavis people called a “boundary of interest” ( http://www.research.ibm.com/people/l/lloydt/color/color.HTM )

        I think that jet would still be a bad choice for such a dataset — one of the things that annoyed me so much about above figure is that the fade-to-dark at both ends of jet made it hard to see where data had high absolute value but oscillating signs. Though, none of the other built-in colormaps really do well with boundary data either (one problem is that the automatic scaling most systems do won’t necessarily put the boundary where you want it.)

  4. Ann said,

    What would those graphs look like with a hot colormap?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 35 other followers