4.7 | 7 ratings Rate this file 81 Downloads (last 30 days) File Size: 4.63 KB File ID: #36212 Version: 1.2
image thumbnail



zhang zhang (view profile)


16 Apr 2012 (Updated )

matlab blue-white-red colorbar, while zero always corresponds to white color. see also darkb2r

| Watch this File

File Information

this matlab file is designed to draw anomaly figures, the color of the colorbar is from blue to white and then to red, corresponding to the anomaly values from negative to zero to positive, respectively.
  The color white always correspondes to value zero.
  You should input two values like caxis in matlab, that is the min and the max value of color values designed. e.g. colormap(b2r(-3,5))
  The brightness of blue and red will change according to your setting, so that the brightness of the color corresponded to the color of his opposite number
  e.g. colormap(b2r(-3,6)) is from light blue to deep red
  e.g. colormap(b2r(-3,3)) is from deep blue to deep red
  I'd advise you to use colorbar first to make sure the caxis' cmax and cmin
  colormap(b2r(-6,8)), colorbar, title('b2r')
  There is also a similar colorbar named darkb2r with colors much darker.


This file inspired Post Glacial Rebound.

MATLAB release MATLAB 7.7 (R2008b)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
06 May 2015 Panayiotis Christodoulies

Excellent for its purpose.

Could I suggest the following:
When cmin is not equal to cmax then either blue or red is not assigned its full color intensity. The assigned colors are chosen and scaled depending on max([cmin,cmax]).
Could the blue and red colors be scaled independently with the most negative value taking the "most blue color" and the most positive value taking the "most red color"?

I used the colormap editor to manually assign to either color its full intensity and then save the colormap. But this defeats the point I guess.


02 Mar 2015 Marcel

Marcel (view profile)

I encounter an error when abs(cmin)>cmax. Adding 1 to start_point in line 90 seems to do the job.

10 Dec 2014 Daniel

Daniel (view profile)

05 May 2014 Chad Greene

Chad Greene (view profile)

I use this several times each week. Thanks for sharing.

25 Nov 2013 Douglas Anderson  
12 Sep 2013 Philippe  
11 Mar 2013 Eowyn Baughman  
09 Apr 2015 1.1

updated: Robert Beckman help to fix the bug when start point is zero, 2015-04-08. The bug exists when setted cmax and cmin is very near but not equal.

09 Apr 2015 1.2

updated: Robert Beckman help to fix the bug when start point is zero, 2015-04-08.The bug exists when the absolute value of cmax and cmin is very near but not equal.

Contact us