File Exchange

image thumbnail

bluewhitered

version 1.0.0.0 (1.86 KB) by Nathan Childress
Blue, white, and red colormap for images with positive and negative values.

102 Downloads

Updated 14 Oct 2003

View License

BLUEWHITERED(M) returns an M-by-3 matrix containing a blue to white to red colormap, with white corresponding to the CAXIS value closest to zero. This colormap is most useful for images and surface plots with positive and negative values. BLUEWHITERED, by itself, is the same length as the current colormap.

Examples:
------------------------------
figure
imagesc(peaks(250));
colormap(bluewhitered(256)), colorbar

figure
imagesc(peaks(250), [0 8])
colormap(bluewhitered), colorbar

figure
imagesc(peaks(250), [-6 0])
colormap(bluewhitered), colorbar

figure
surf(peaks)
colormap(bluewhitered)
axis tight

Cite As

Nathan Childress (2020). bluewhitered (https://www.mathworks.com/matlabcentral/fileexchange/4058-bluewhitered), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (39)

Irsalan Arif

Very useful. Thanks

Penning Yu

It works very well. As already mentioned by Fabian Konrath, you can make colorbars of subplots with different colormaps using colormap(gca,bluewhitered(256)); instead of colormap(bluewhitered(256)); .

Penning Yu

It works very well. As already mentioned by Fabian Konrath, you can make colorbars of subplots with different colormaps using colormap(gca,bluewhitered2(256)); instead of colormap(bluewhitered2(256)); .

Baoqing Lu

Very nice function. Thank you very much! I like your choice of colors, which makes the contrast more conspicuous and thus the figures more readable.

Zaid Alattabi

Thank you, it is very useful and easy to apply it

Camille Brais

Christian Karcher

Floris van Rees

Hongyang Zhou

Hiuri Noronha

this looks perfect for simulating electromagnetic waves, thank you!

Hiuri Noronha

Mohan Mond

Tunechi

This is Good, we need more matlab colormap like this in the default choices.

Fabian Konrath

Thanks for this useful function!
Regarding the reported bug when this function is called multiple times: You can bypass this issue by specifying the axis handle when calling colormap(). For example: colormap(gca,bluewhitered)

Ronja Paffrath

This one is awesome, thanks a lot.
Is there a way to set the white to a value of 1?

Ajey Venkataraman

Like the other user mentioned already, there is a bug that shows up when the function is called several times. It affects the colormap as a whole.

dbdq

It has a color scaling bug when called multiple times for subplots: the scale is affected globally over all subplots.

dbdq

Amir

Thanks for the nice package. How can I make sure that white corresponds exactly to 0? Tried to play with the argument of bluewhitered but still not sure If the outcome is solid.

Amir

Jiangfeng Wu

Roobaert Alizee

Hello thanks! very useful. SAme question than Kira: how do I set missing data (Na,NaN) colour? Currently its showing white. Would love to set it at a different color to shot that it is missing data.

Marko Peric

Very useful!

Michael Marquis

Mingzhe Liu

Congyue Cui

Mariangel garcia

Kira Moriguchi

Hi, how do I set missing data (Na,NaN) colour? Currently its showing white. Would love to set it at a different color to shot that it is missing data.

Jim

Thanks Nathan. I've been using the redblue colormap (Adam Auton, 9th October 2009), and then opening the colormapeditor and manually dragging the white marker to the zero point on the c-axis. For what it's worth, to use your function to imitate these manual steps, I use "colormap(redblue)" before calling it (which just sets the colormap length equal to the redblue colormap), I hacked your top/bottom/mid-point RGB triples to match the redblue map:

% original RGB triples
%bottom = [0 0 0.5];
%botmiddle = [0 0.5 1];
%middle = [1 1 1];
%topmiddle = [1 0 0];
%top = [0.5 0 0];

% mimics redblue colormap gradations
bottom = [0 0 1];
botmiddle = [0.5 0.5 1];
middle = [1 1 1];
topmiddle = [1 0.5 0.5];
top = [1 0 0];

Thanks again for this useful function.

Roni Pozner

Just what I needed

Jing Tang

Hi,

Very nice function. I have question. Is it possible to change the white color to grey or black, since it cannot show it in the white document?

Thanks a lot.
/Jing

Ste

It's a great function! the only problem I encounter is when I try to fix the colorbar (with caxis). The zero does not stay in the same place (at the white)but moves to red or blue.. Anyone an idea how to solve that?

Sandra

Kim Bostroem

Absolutely useful. Incredible that it's not included in MATLAB already!!!

Kazem Edmond

EXACTLY what I needed. Thanks so much.

John Doe

cool! good work!

cynthia solly

Johnny Cash

useful

Yannis Cuypers

Usefull, such a colormapwas actually missing in Matlab

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!