Skip to content
/ cmap Public

Perceptually uniform colormaps for MATLAB, compiled from multiple sources.

Notifications You must be signed in to change notification settings

tsipkens/cmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perceptually uniform colormaps for MATLAB

NOTE: All rights to the original authors. For licensing see information for individual sources in Colormap sources. Custom colormaps new to this work are released under a MIT License.


This repository contains files for colormaps, mostly compiled from multiple, external sources (see dedicated section below), with some custom colormaps that are specific to this package. After making a copy of the folder locally, the next step in their use is to add the parent folder to the sample project, e.g.,

addpath cmap; % add cmap folder to the MATLAB path

Then colormaps can be loaded by calling the functions that share their name. For example, you can get the color data for the viridis colormap using,

cm = viridis; % return colormap data to cm

or apply it to a plot using

colormap(viridis); % apply viridis to a plot

Optional arguments to these functions allow for changing the number of colors in the colormap. For example, getting the 100-color equivalent of viridis,

viridis(100); % interpolate to 100 colors in RGB space

By default, this will use linear interpolation in RGB space. Alternatively, interpolation can be done in HSV space by appending 'hsv' as an additional argument:

viridis(100, 'hsv'); % interpolate to 100 colors in HSV space

Note that the deep, dense, matter, and tempo colormaps are reversed from their original order, such that the darker color is always first. The colormaps, and swages indicating their color progression, are included at the end of this README.

Colormap sources

Sources of these colormaps include:

matplotlib

Colormaps designed by Stéfan van der Walt (https://github.com/stefanv) and Nathaniel Smith (https://github.com/njsmith). More information is available at https://bids.github.io/colormap/. Released under a CCO license. You can learn more about the science behind the creation of these kinds of colormaps by watching their presentation of viridis: https://youtu.be/xAoljeRJ3lU. The cividis colormap is a variant of ‘viridis’ developed by Jamie R. Nuñez, Christopher R. Anderton, and Ryan S. Renslow.

cmocean

More information is available at https://matplotlib.org/cmocean/. Released under a MIT license. The colormaps are associated with: Kristen M. Thyng, Chad A. Greene, Robert D. Hetland, Heather M. Zimmerle, and Steven F. DiMarco. True colors of oceanography: Guidelines for effective and accurate colormap selection. Oceanography, September 2016. http://dx.doi.org/10.5670/oceanog.2016.66.

colorbrewer

Colormaps by Cynthia Brewer and Mark Harrower. More information available at http://colorbrewer2.org/. Released under an Apache License. For diverging colormaps, the order of colors was made consistent with the colormap names. For sequential colormaps, orders were adjusted such that darkest colors appear first. Original colormaps can be restored by using MATLAB's built-in flipud(...) function of the altered colormaps.

cmasher

A collection of scientific colormaps for making accessible, informative and cmashing plots in Python. More information is available at https://github.com/1313e/CMasher and https://cmasher.readthedocs.io/. Released under a BSD 3-Clause License.

turbo

A. Mikhailov. Turbo, An Improved Rainbow Colormap for Visualization. More information is available at https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html. Released under an Apache License.

seaborn

Originally for Python by Michael Waskom. For supporting discussion see README at https://github.com/mwaskom/seaborn and https://seaborn.pydata.org/tutorial/color_palettes.html. Released under a BSD 3-Clause License.

scientific

A set of scientific colour maps by Fabio Crameri. Released under an MIT License. Citable at:

Crameri, F. (2018). Scientific colour maps. Zenodo. http://doi.org/10.5281/zenodo.1243862

custom

A set of custom colormaps specific to this package. The custom colormaps are only approximately perceptually uniform.

Other resources

A catalogue of colormaps for Julia can be found here: Catalogue of ColorSchemes.

Sweep through colormap

The cmap_sweep(n, cm) function is also included to sweep through colours in a standard MATLAB plot. To demonstrate we first generate some synthetic data with a set number of lines:

n_lines = 40; % number of lines to plot

addpath supplement; % add supplemental functions / scripts

% generate test data
y = test_data(round(n_lines*2.5), 300);
y = y(:, 1:n_lines);

Then, one can sweep through the viridis colormap using:

figure(1);
cmap_sweep(n_lines, inferno); % set colororder for plot
plot(y); % plot data

A sample plot generated using this procedure (Sipkens et al., Submitted):

Catalogue

Sequential colormaps

Sequential colormaps have a monotonic change in perceived brightness. Colormaps consistently proceed from the darkest to the lightest colour.

matplotlib

cividis

inferno

magma

plasma

viridis

cmocean

deep

dense

haline

oxy

ice

matter

speed

tempo

thermal

colorbrewer

blues

bupu

gnbu

greens

pugnbu

purd

purples

rdpu

reds

ylgnbu

cmasher

eclipse

ember

lavender

nuclear

ocean

rainforest

seaborn

crest

flare

mako

rocket

scientific

acton

buda

devon

hawaii

imola

lajolla

oslo

tokyo

custom

fblue

fgreen

fred

fpurple

internet

fmviz

Divergent colormaps

Divergent colormaps have the brightest or darkest color in the middle, with a monotonic change in perceived brightness in either direction. Note that the colorbrewer colormaps are in the order of the characters (for example, RdBu starts with red and goes to blue). The balance colormap from cmocean has been renamed to balanced, to avoid a name conflict with a native MATLAB function.

cmocean

balanced

curl

delta

colorbrewer

brbg

rdbu

rdylgn

piyg

prgn

puor

spectral

scientific

cork

roma

vik

custom

weather

turbo

turbo

Cyclic colormaps

These colormaps start and end with the same colour.

scientific

bamo

corko

romao

viko

About

Perceptually uniform colormaps for MATLAB, compiled from multiple sources.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published