These colormaps were developed by Kristen Thyng using viscm. They are perceptually uniform, as color should be when it serves as a numeric axis.
If these colormaps are 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
Thyng, Kristen, et al. “True Colors of Oceanography: Guidelines for Effective and Accurate Colormap Selection.” Oceanography, vol. 29, no. 3, The Oceanography Society, Sept. 2016, pp. 9–13, doi:10.5670/oceanog.2016.66.
Great colormaps! I use them a lot.
It worked Chad.
I was not specifying the axes in the colormap code and since I have several axes/figures in the GUI, it was not working properly.
The line colormap(gca, parula) [in my case colormap(handles.axes3D, parula)] is enough. Beginners mistake :) Many thanks, it is looking great!
@Melo: To change back to parula, try
Very nice contribution Chad. There are some great looking colormaps in this one.
Just a question, I am changing the colormaps in a GUI by just running the cmocean('ColormapName') code in a pushbutton. It works, however, if I want to change back the colormap to parula (or any other MATLAB colormap) it does not change. I can only change to a cmocean-based colormap after running the cmocean() function. I have to close the GUI figure and reopen it again. So I am thinking I should reset some color scheme or something to make it work? Can you help me?
@Chad: Thanks for the workaround. Yeah, it's (yet another)one of those things that Matlab is a bit of a pain...
I will do what you have suggested.... Mainly the first line of code :)
@Benoit: Thanks for the feedback! There are several ways to deal with Add-Ons, but it sounds like the best solution for you is to add the path in a startup.m file. By default, Matlab always looks in the Home directory for a file called startup.m, and runs it automatically when Matlab starts. So create a file called startup.m, save it in your Home directory, and include any lines of code that you want to run every time Matlab starts. Mine contains these lines:
set(0,'DefaultFigureColor',[1 1 1])
The addpath(genpath(...)) lines add the path to all files and subfolders inside the /data and /functions folders.
Awesome library! 5 stars to you (and 0 stars to Matlab).
I have downloaded and installed the Toolbox. I tried the example and it did not work: "Undefined function 'cmocean' for input arguments of type 'char'.". I checked my Add-on manager (by clicking in Matlab's 'home' tab, on the arrow bellow 'Add-ons' and finally 'Manage Add-ons') and the toolbox displays as installed and active. I found it strange, so I restart Matlab, same behaviour. So I decide to try to re-install the toolbox.
After a few attempts downloading and installing the Toolbox, I decided to try to run the script containing the 'cmocean' function.
To locate that script, you need to go to the Add-on manager, right click on the 'cmocean toolbox' and then click on 'open folder'.
Then I press run in the 'Editor' tab.
Matlab complains, says the directory of that file is not known (assuming you do not change your working directory" and gives you the option to 'cancel', 'change folder', 'add path' or 'help'. I clicked on 'add path' and voilà.
Downside: I need to do this every time I start Matlab.
If anybody has a suggestion how to tackle this, I would be happy to know.
PS: Matlab R2019a
Excellent codes, very well done.
Nice set of functions for extending the default set of colormaps.
Thanks Phelype! I've updated the function as per your suggestion.
I also stumbled upon the problem with the using the number of levels and the 'pivot' argument.
This is a bug in the argument parser. I propose the following fix:
Change the line (150) that says:
tmp = any([strncmpi(varargin,'pivot',3) strncmpi(varargin,'zero',3)]);
tmp = strncmpi(varargin,'pivot',3) | strncmpi(varargin,'zero',3);
It works for me after this change.
Hi, first off - this is a really helpful and great looking set of colours!
I came across the same problem as Andrea these days, and worked on a solution which works satisfactorily for me. I am happy to share, just don't know how to do this best.
Is it possible to specify the number of levels AND a pivot value?
For example: cmocean('balance',12,'pivot',0)
I seem to cannot make it work. It does the same as cmocean('balance','pivot',0) ignoring the number of levels
Thank you Chad. That definitely helps. Maybe one of those could be an optional argument?
And thank you for directing me to the colorspace package.
Thanks for the feedback. I see what you're saying about the off-white values in the center of the colormaps. These colormaps are the ones described in the paper published in Oceanography, and I think the rationale for not quite going all the way to pure white was to keep the colormap from blending in with a white background. I'm a bit colorblind myself, so I don't feel qualified to tinker with the colormaps. If you'd like to tinker on your own, get Pascal Getreuer's wonderful colorspace transformation function and try this:
C = cmocean('delta');
% Convert the colorspace:
hsl = colorspace('rgb->hsl',C);
% The lightness is the third column:
L = hsl(:,3);
% Make the peak white by setting its lightness to 100%
% Shift the lightness up a little to lighten the entire colormap:
L2 = L + (1-max(L));
% Or stretch the lightness values if you prefer to keep the low ends:
L2 = L/max(L);
% Convert back to RGB:
C2 = colorspace('hsl->rgb',[ hsl(:,1:2) L2]);
plot(L,'b'); hold on;
Thank you for creating these colormaps! They have been extremely useful.
I do have some comments about the divergent colormaps. The center value doesn't come out white. For the delta colormap it returns an ugly yellow tinge to the background. The curl colormap leaves a slight red, and balance leaves an even slighter red. I have tried to use the zero/pivot command and it has not made a difference.
The issue appears to lie in the autopivot section (the code block after line 212). There is no specification that an RGB value of [1 1 1] should be returned in the middle of the colormap. Can this please be added into the code? It will be a fantastic improvement so that the background will actually be white.
As a lowly graduate student I certainly appreciate the citations, thanks. The cmocean colormaps are available in GMT-friendly cpt format here: https://github.com/kthyng/cmocean-gmt
Sorry, my mistake, 0 -> blue just as you say.
OT: Will definitely cite Thyng et al in my next paper, hopefully out before summer. Any plans for a GIS package?
Thanks for the kind words.
The "ice" colormap is designed to mimic the way sea ice looks in the ocean. Zero concentration of sea ice looks like a dark blackish blue, whereas 100% sea ice cover is nearly pure white.
If you prefer to flip the order of any colormap, the flipud command is one way to do it. A simpler way is to use the - sign when you call the colormap. For example,
Let me know if you think of other ways cmocean can be more user friendly or improved in any way.
Very good, thanks! To make it even better, maybe the "ice" colormap should be inverted in the package? It´s easy enough to use "flipud" to fix it, but maybe not for a beginner.
wish extend as python can be added
Thanks very much, seems the behavior of either imread or image changed; to get the correct image in release R2016b when doing cmocean with nargin==0, line 104 of cmocean should be
Inspired by: Oceanographic Data Visualized with MATLAB, CMRmap.m, Color Palette Tables (.cpt) for Matlab, Modified CMRmap, CubeHelix Colormap Generator: Beautiful and Versatile!, ColorBrewer: Attractive and Distinctive Colormaps, Mixing (MX) Oceanographic Toolbox for EM-APEX float data, jLab: A Matlab toolbox for data analysis, Argo Toolbox, Colorspace Transformations
Inspired: xcorr3, EOF, crameri perceptually uniform scientific colormaps, Cyclic color map, MPAPASS - EV Multiplex Software, anomaly, How to estimate subglacial water routes, Intuitive RGB color values from XKCD, MatPlotLib Perceptually Uniform Colormaps, Daily Antarctic sea ice concentration, Arctic Sea Ice, Antarctic Mapping Tools
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!