File Exchange

image thumbnail

Cyclic color map

version 1.1.1 (1.57 MB) by Chad Greene
A constant-lightness cyclic colormap for phase.

19 Downloads

Updated 20 May 2019

View License

Three functions are included here:
1. phasewrap easily wraps data to the range -180 to 180 or -pi to pi.
2. phasemap is a constant-lightness cyclic colormap developed by Kristen Thyng. The constant lightness is good for displaying phase because it does not put strong emphasis on any part of the color map. A well-written and aesthetically-pleasing overview of Kristen's cmocean colormaps can be found here: http://matplotlib.org/cmocean/
3. phasebar makes a circular colorbar.

The phasemap colormap is from the cmocean package, and we've written a peer-reviewed paper about cmocean which has just come out in the journal Oceanography. If these phasemap is useful for you, please consider citing our paper:

Thyng, K.M., C.A. Greene, R.D. Hetland, H.M. Zimmerle, and S.F. DiMarco. 2016. True colors of oceanography: Guidelines for effective and accurate colormap selection. Oceanography 29(3):9–13. http://dx.doi.org/10.5670/oceanog.2016.66

Cite As

Chad Greene (2019). Cyclic color map (https://www.mathworks.com/matlabcentral/fileexchange/57020-cyclic-color-map), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (11)

Chad Greene

Great question, Knut! To place the phasebar outside the axis limits, do

ax = phasebar(...);
ax.Position = [lowerleftx lowerlefty width height];

By default, the position units are scaled from 0 to 1 relative to the figure.

This is great! I am just wondering about one thing: is it possible to place the phasebar outside of the figure, like the ordinary matlab colorbar?

Chad Greene

@Brian, agreed, that would be great if it were possible, but in this particular case we're somewhat limited by physics. A key feature of this colormap is that is is perceptually uniform *and* it is cyclic. That's mighty hard to accomplish without exploiting multiple hues.

For typical linear colormaps that represent low valued numbers to high valued numbers without needing to wrap back around, it is easy to obtain perceptual uniformity without variations in hue, because most of what we perceive is related to lightness. A cyclic colormap that varies in lightness would put necessarily include bright spots and dark spots that would put local emphasis on arbitrary values. Without varying lightness, all we're left with is hue and saturation.

A further constraint is that a cyclic colormap must contain at least three distinct regions so viewers can determine the direction of increasing or decreasing phase. This makes it mighty difficult to get perceptually uniform periodicity without including some red and green.

As a colorblind person myself, I am certainly sympathetic to the plight, but note that the vast majority of persons labeled as colorblind are not completely colorblind. The most common form of colorblindness is red/green, and that's the kind I have, but I can still see some reds and some greens. The cmocean 'phase' colormap here isn't ideal for me, but it's certainly better than something perceptually nonsensical like hsv.

Brian

Thanks! Would be great to have a colorblind-friendly version of this (journals are moving away from reliance on red/green contrasts). "Universal color design" http://jfly.iam.u-tokyo.ac.jp/color/

Howard Lam

Sim Mah

Wonderful job.
Many thanks

Oh, I see. I'd thought "phasemap" was intended as a subfunc to the others. I appreciate your clarification; so I agree there's no reason to break out the colormap data array.

Chad Greene

Carl, Can you explain what you mean by standalone data array? If you want a text file of RGB values, you can copy the RGB values from phasemap.m. Or you can save them as a .mat file if that's what you're looking for.

When would a user have access to a separate standalone data file, without having access to phasemap.m? The phasemap function was designed to behave like the built-in colormaps like jet, parula, etc. What kind of syntax or behavior are you seeking?

Hi Chad, it's a matter of programming style, maybe, but I'd rather have the data array stand alone from the function. If you supplied the phasemap array separately and set it as a default argument to phasemap.m, then not only would the data be available when the function isn't, but you could modify arbitrary colormaps with the phasemap.m function.

Chad Greene

Hi Carl--Typing

M = phasemap;

gives the 256x3 data array. Is that what you mean?

Minor request: pull the colormap out of the function and provide it as a standalone data array so we can use it with our own scripts and functions.

Updates

1.1.1

Added live scripts

1.1.0.0

License update.

1.1.0.0

Added links to our new paper about cmocean.

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor