RedBlue Colormap Generator with Zero as White or Black

バージョン 1.0.1 (223 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