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
Nathan Childress (2021). bluewhitered (https://www.mathworks.com/matlabcentral/fileexchange/4058-bluewhitered), MATLAB Central File Exchange. Retrieved .
Inspired: scalar2colormap, MRIqual, NAWHIMAR Navy-White-Red Divergent Colormap with Automatic Scaling, NIfTI Studio
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
Very useful. Thanks
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)); .
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)); .
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.
Thank you, it is very useful and easy to apply it
this looks perfect for simulating electromagnetic waves, thank you!
This is Good, we need more matlab colormap like this in the default choices.
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)
This one is awesome, thanks a lot.
Is there a way to set the white to a value of 1?
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.
It has a color scaling bug when called multiple times for subplots: the scale is affected globally over all subplots.
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.
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.
Very useful!
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.
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.
Just what I needed
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
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?
Absolutely useful. Incredible that it's not included in MATLAB already!!!
EXACTLY what I needed. Thanks so much.
cool! good work!
useful
Usefull, such a colormapwas actually missing in Matlab