I believe it was almost four years ago that we started kicking around the idea of changing the default colormap in MATLAB. Now, with the major update of the MATLAB graphics system in R2014b, the colormap change has finally happened. Today I'd like to introduce you to parula, the new default MATLAB colormap:
(Note: I will make showColormap and other functions used below available on MATLAB Central File Exchange soon.)
I'm going spend the next several weeks writing about this change. In particular, I plan to discuss why we made this change and how we settled on parula as the new default.
To get started, I want to show you some visualizations using jet, the previous colormap, and ask you some questions about them.
Question 1: In the chart below, as you move from left to right along the line shown in yellow, how does the data change? Does it trend higher? Or lower? Or does it trend higher in some places and lower in others?
fluidJet hold on plot([100 160],[100 135],'y','LineWidth',3) hold off colormap(gca,'jet')
Question 2: In the filled contour plot below, which regions are high and which regions are low?
The next questions relate to the three plots below (A, B, and C) showing different horizontal oscillations.
Question 3: Which horizontal oscillation (A, B, or C) has the highest amplitude?
Question 4: Which horizontal oscillation (A, B, or C) is closest to a pure sinusoid?
Question 5: In comparing plots A and C, which one starts high and goes low, and which one starts low and goes high?
subplot(2,2,1) horizontalOscillation1 title('A') subplot(2,2,2) horizontalOscillation2 title('B') subplot(2,2,3) horizontalOscillation3 title('C') colormap(jet)
Next time I'll answer the questions above as a way to launch into consideration of the strengths and weaknesses of jet, the previous default colormap. Then, over the next few weeks, I'll explore issues in using color for data visualization, colormap construction principles, use of the L*a*b* color space, and quantitative and qualitative comparisons of parula and jet. Toward the end, I'll even discuss how the unusual name for the new colormap came about. I've created a new blog category (colormap) to gather the posts together in a series.
If you want a preview of some of the issues I'll be discussing, take a look at the technical paper "Rainbow Color Map Critiques: An Overview and Annotated Bibliography." It was published on mathworks.com just last week.
Get the MATLAB code
Published with MATLAB® R2014b
Comments are closed.
19 CommentsOldest to Newest
When can we expect a real overhaul of the JIT engine of MATLAB?
There has been majoe development in that field.
Modern JIT engines (Google’s V8, LUA and Julia) offer performance which is close to compiled code.
When can we have it in MATLAB?
We really need MATLAB to get faster, real faster.
Royi—Normally, I restrict comments to be relevant to the posted topic, but I appreciate your feedback about MATLAB. As a matter of long-standing policy, we rarely say anything in public forums about future product plans.
Thank you for accepting my comment.
I wrote it as I see big changes in MATLAB (The UI in 8.x, the Graphics in R2014b) which are all blessed and great by themselves (And very well executed).
Yet I saw nothing targeted what’s most important in my opinion – Performance of the code.
I think, with today’s performance of the latest Script languages, we might use MATLAB in operational code.
We just need the JIT engine for that.
It was a really pleasant surprise to see the introduction of a perceptual colormap in MATLAB, and especially the guts it took to make it the default – bravo! :) Maybe future releases could have a few more options, even if they aren’t as theoretically ‘perfect’ as parula, it’d be nice to have a few different-looking perceptual colormap choices available.
Eric—Thanks for the kind words! I admit that I was a bit hesitant at one point about whether to change the default. Two things happened to increase my confidence in the decision. First, a customer in an early feedback program complained that the new colormap looked “noisy.” I realized that the customer’s data was noisy, and the jet colormap was hiding that. Second, someone extremely familiar with the jet colormap gave me an eye-opening answer to Question1 in the blog post above.
And thanks also for the suggestion to expand the colormap choices.
Although Royi may be off-topic he is making an important point here in my opinion: SPEED
I wish your first R2014b related post would have been: HG2 makes image rendering 10x faster
New Colormap, graphics smoothing, Object Dot-Notation, etc. may be welcomed by many MATLAB users, but I was looking for rendering speed since I first heard rumors about HG2 a few years ago.
hFig = figure(); hAxes = axes('Parent',hFig); rgb = zeros(1080,1920,3,'uint8'); hImg = image(rgb,'Parent',hAxes); set(hAxes,'Visible','off'); times = zeros(1,3); tic for i = 1:255 tic rgb = rgb + 1; times(1) = times(1) + toc; tic set(hImg,'CData',rgb); times(2) = times(2) + toc; tic drawnow times(3) = times(3) + toc; end times % Frames per second tEnd = toc; fprintf('Frames per second: %.0f\n',255/sum(times));
actually runs slower on R2014b compared to R2014a on my DELL T3610 with NVIDIA GTX980, unless you switch to drawnow expose, which is not what I want. At least setting CData is significantly faster but drawnow eats it all up again.
I feel that JAVA is limiting MATLAB very much in the field of video, although I understand that MATLAB image rendering may just be fast enough for most users.
No offens, Steve, but I am disappointed about HG2. Don’t get me wrong, I am a 9to5 MATLAB user since 10years and it’s the language I like to use. The GPU computing stuff that matured over the last years is very useful for image processing. In that context setting CData with gpuArrays would be highly appreciated, assuming that data is not making the roundtrip via the CPU. I am sure MATHWORKS thinks about that already. So +1 from me here.
ps.: HG2 has basically broken font rendering using “text” on every platform, unless you turn off “FontSmoothing” (Although I am sure there are good technical reasons for that, it is unacceptable)
pps.: No need to publish this – won’t help anyone.
Oliver—Thanks. I have passed your comments along to the graphics team. Can you say more about what you mean with respect to text rendering? What I see on my screen looks good.
Oliver—The graphics team is already looking at your benchmark, so thanks for sending it. One follow-up question for you: Why is drawnow expose not appropriate for you?
IMHO, the ‘value’ of making parula the default is worth the user ‘pain’ induced by the change, if it prevents a single instance of false data interpretation in an application in the life sciences, safety-critical aerospace/automotive/space, engineering thermodynamics/fluid dynamics, etc. And given the size of the worldwide MATLAB user base, I’d say this is a pretty safe bet… On that note, what about making a parula.m colormap generator m-file available as an official TMW file exchange item, for folks to use pre-2014b? The help text could even include a suggestion on how to set it as the default colormap using startup.m,
One question I do have – I noticed that the top end of the colormap is a shade of yellow. Is that not going to cause any issues with contrast on LCD monitors, especially projectors? That’s why I thought that yellow text (esp on a white background, such as the stock figure background) was not recommended to be used in presentations intended to be shown on projectors.
Font Rendering using “text”, not uicontrol(‘Style’,’text’), looks blurry instead of smoothed to me. I assume no sub pixel smoothing ala ClearType is done. Just start “bench” and you will immediately notice the difference between the figures. On my Retina MacBook the bar plot labels are nearly unreadable, while the table plot is crisp. On Windows with 1920×1200 it’s not that bad but still inferior to ClearType. This was not the case with R2014a.
drawnow expose is not an option because it does not handle the system events, especially the mouse click callbacks. Imagine an interactive video player that you cannot stop after start.
Eric—Thanks. I’m with you on the value of the colormap change. Parula has actually been quietly shipping with MATLAB since R2013b. I’ll look into other options.
Regarding yellow … well, the overall set of design criteria makes the whole problem highly over constrained. If we want monotonically increasing lightness to provide the appropriate perceptual cues and to assist color-impaired viewers, then the top of the colormap is going to be pretty bright and not have much contrast against white. I don’t think that will be a problem very often in practice, though, because what you’re really getting is contrast with the rest of the data, not contrast against a white background. I’m sure there will be some cases where it’s not ideal, but it’s difficult making one colormap that works in every scenario. Working well with projectors turns out to be a pretty tight constraint. Go to ColorBrewer site and check the box that says “projector friendly.” It eliminates almost everything.
PS. Nice alternative bird image!
Oliver—Thanks for the additional details. It’s helpful.
Hi Steve – very interesting. I read in one of the comments about “perceptual colormap” – I hope you will be expanding upon this in future blog posts.
On a related note, today I came across two interesting articles related to using color for maps and how rainbow color maps have drawbacks.
Aditya—Yes, I will be talking about various colormap issues, including the concept of perceptual uniformity. I saw the Wired article, too. Cynthia Brewer’s ColorBrewer is mentioned by everyone who says anything about using color scales for data visualization.
Steve, what do you think about the colormaps presented on this page/paper as potential future inclusions?
Eric—People started asking me about divergent colormaps as soon as I started blogging about the new default colormap. I’m interested. We’ll see.
At some point I’ll probably post an explanation on the blog of how to display data in MATLAB using divergent colormaps.
Steve, thanks for putting together the nice overview/bibliography in your technical report. I found this to be very useful and it contained some references I wasn’t aware of. In future versions of the report you might consider adding a reference to our work in the statistical literature on choosing colors in HCL (or LCH) space. It yields rather similar palettes compared to ColorBrewer.org but gives explicit formulae for selecting colors along paths in HCL space. The method is described in doi:10.1016/j.csda.2008.11.033 and a recent application to meteorological maps is in doi:10.1175/BAMS-D-13-00155.1. We have collected further links/references at http://hclwizard.org/.
Thanks & best wishes, Achim
Steve – can you put showColormap on File Exchange?
Nick—Yes. I meant to do that earlier.