RedBlue Colormap Generator with Zero as White or Black

版本 1.0.1 (223.5 KB) 作者: Mirko Hrovat
A colormap generator to display positive values as blue and negative values as red. Zero is displayed as either white or black.
1.3K 次下载
更新时间 2020/5/4

查看许可证

Generates a RED-BLUE colormap with zero as white or black. Positive values are displayed as blue intensities and negative values are displayed as red intensities. Zero can be selected to be either white or black. The clim values, from the image or can be entered, are used to customize the colormap.

Syntax: y = redblue(n,clim,'black')
Typical usage: colormap(redblue(64))

Arguments:
All arguments are optional and can be in any order.
n - number of color levels (default is # of colors of current colormap)
clim - two element vector specifying the color limits (default: current axis color limits)
black - string ('k' or 'black') specifying zero as black (default is zero as white)

This creates a custom colormap for any image. The colorbar scale will be skewed toward red or blue depending on the caxis values (clim) of the image.

Two versions:
redblue.m - This version flattens the edges of the colormap to improve the visualization of the
gradient. The effect works better for larger values of n.
redblueu.m - This version uses a uniform scaling for red and blue. The white and black will appear
to be a larger section.

Keep in mind that if the scale is very skewed, there will not be much of a color gradient. The gradient can always be increased by using your own clim values.
% Example:
% y = caxis; % e.g. y = [-11,-5]
% colormap(redblue(64) % and not much gradient
% colormap(redblue(64,[-11,0])) % white is at -5 with a larger gradient

引用格式

Mirko Hrovat (2024). RedBlue Colormap Generator with Zero as White or Black (https://www.mathworks.com/matlabcentral/fileexchange/74791-redblue-colormap-generator-with-zero-as-white-or-black), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2017a
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.1

Colormap generating algorithm now accounts for the case when the differences in the clim limits is very small.

1.0.0