matteocourthoud / centered-colormap

MATLAB function to make divergent colormaps with the color white always centered on zero.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Centered Colormap

by Matteo Courthoud

function file: centered.m

example file: example.m


This package provides colormaps centered on the white color corresponding to zero. Just specify centeredas an argument to a colormap to use the default centered colormap.

surf(peaks(25)+2);
colormap(centered), colorbar

example1

Even if the scale is asymmetric (positive), the palette has the color white centered on zero.

The function takes different color palettes as arguments.

palettes

For example, we can use the BrBg palette.

contourf(peaks(25)-2,25,'linestyle','none'); 
colormap(centered('BrBg')), colorbar;

example2

Again, even if the scale is asymmetric (negative), the palette has the color white centered on zero.

About

MATLAB function to make divergent colormaps with the color white always centered on zero.

License:MIT License


Languages

Language:MATLAB 100.0%