colormap_CD toolbox has been upgraded to version 2.0!
The major update is the inclusion of several build-in functions that allows you to generate beautiful and clearly distinguishable color palettes without calling the colormap_CD.m function.
Advanced users can still tune colormap_CD.m to customize their own color palettes that are much more distinguishable by human eyes compared with the standard Matlab colormaps. In any cases, I guarantee that you do not need to worry about the counter intuitive RGB values. All you need to do is tell colormap_CD.m what colors you want to use and how bright you want them to be!
If you run:
col = r2bCD;
You get a nice blue-to-red colormap:
Compared to a typical Matlab blue-to-red colormap (before), which uses saturated but very bright red and blue at the two ends, it is apparently much easier to read the values using colormap_CD V2.0 (after), especially for the __red __colors.
Another example is the widely used jet colormap. Compared to the default version in Matlab, besides that red is more distinguishable, colormap_CD V2.0 does not highlight yellow and cyan, so that different hues are more balanced and the figures can be stared for a longer time without tiring your eyes.
Or if we compare with the hot colormap, again colors are not distinguishable for the glaring yellow and flashing red (before). But colormap_CD V2.0 allows you to read clearly where each contour line locates.
Finally, if you want to explore the details of your data, one way that uses colormaps coming with Matlab is lines, which gives you a painting of Picasso... Of course, there is no way to read any values in the left panel. But colormap_CD V2.0 allows you to examine the details of data easily and clearly.
colormap_CD V2.0 provides several build-in functions that allows you to generate a more distinguishable and non-glaring version of most widely used colormaps. Here list all the build-in functions and their possible variations.
This function generate double-hue colormap. Run:
col = r2bCD;
You can use argmument "num" to choose number of colors in individual hues. Foe example:
col = r2bCD(9);
There is also a "name" argument, which allows to take value of "precip" and returns a colormap for precipitation anomalies:
col = r2bCD(6,'precip');
This function generate gray to red colormap, which is often the case when some part of the visualization needs to be emphasized. Run:
col = g2rCD;
Again, in all of the build-in functions, it is always available to tune the "num" argument. The "name" argument allows you to do:
col = g2rCD(6,'s2g');
col = g2rCD(6,'g2b');
This function generate rainbow-like colormap. Run:
col = jetCD;
The "name" argument allows you to do:
col = jetCD(6,'season');
Note that this colormap starts and ends with bluish colors, which is suitable to code periodic variable, e.g. seasonal cycle (cold winter) and diurnal cycle (cold night). In addition, this colormap has two transit colors (magenta and green), which allows readers to distinguish between spring and fall or morning and afternoon.
This function generate single-hue colormap. Run:
col = hotCD;
The "name" argument allows you to go through every major hue:
col = hotCD(6,'y');
col = hotCD(6,'g');
col = hotCD(6,'c');
col = hotCD(6,'b');
col = hotCD(6,'m');
col = hotCD(6,'gry');
This function is usually called during data exploration period, which generates colormaps that distinguish between the minor changes in the value.
col = detailCD;
The "name" argument allows you to show details of both positive and negative values.
col = detailCD(6,'double');
Note that you can always use the following command to reverse the order of colors.
col = flipud(col);
colormap_CD.m allows you take colors on a 2-D plane by changing the hue and brightness of colors. Compared to a standard Hue-Saturation-Brightness color encoding scheme, colormap_CD.m fixes the saturation parameter and simplifies the process of finding colors.
A coarsened color palette used by colormap_CD.m is shown below:
RGB_out = colormap_CD(hue,brt,gry,num)
Hue of colors, valid values are from 0 to 1 (see above color palette).
The dimension of hue should be a n x m, where: n is number of groups of colors, which can take value for all integers. m represents number of colors in each group, which can take values in {1,2}.
When n = 1, the colormap has one group of hues. For example:
col = colormap_CD([0.16 0.89],[1 0.3],[0],12);
In the above example, m = 2, so colors in the colormap change their hue linearly from yellow to magenta. Otherwise, all colors have exactly the same hue and can only vary in brightness.
Another example would be an improved version of Matlab Autumn colormap:
col = colormap_CD([0.96 0.16],[0.3 0.8],[0 0],12);
When n = 2, the colormap has two groups of hues. For example, the classic blue-to-red :
col = colormap_CD([ 0.45 0.7; 0.08 0.95],[1 .35],[0 0],6);
It can also be used to generate rainbow-like palette:
col = colormap_CD([0.45 0.70; 0.25 0.9],[0.7 0.35],[0 0],6);
when n > 3, the colormap has multiple groups of hues, which stack the colormap of each group of hues by n times. For example, the following palette can be used to show details:
col = colormap_CD([0 1/6 1/3 2/3 5/6 1]',[0.9 .35],[0 0 0 0 0 1],5);
In this example, m = 1, so only one hue is allowed in each segment of the colormap.
Brightness of the colors, valid values are from 0 to 1 (see above color palette).
The dimension of brt should be 1x2, which represents the brightness of colors on the two ends of each segment. For example, the following line has colormap varying from white (brt = 1) to dark magenta (brt = 0.3):
col = colormap_CD([0.16 0.89],[1 .3],[0],12);
logics that determines whether certain hues are in gray scale, valid values are {0, 1}, and the size of gry should be 1 x n, where n is number of groups of hues. When gry = 1, corresponding hues are in gray scales. For example:
col = colormap_CD([ 0.45 0.7; 0.08 .95],[.95 .35],[1 0],8);
col = col([1:8 10:2:end],:);
Number of colors in each hue.
Two reasons make colormap_CD V2.0 works better than default Matlab colormaps:
-
colormap_CD V2.0 allows users to take dark colors, brightness < 0.5, where as conventional colormaps are confined in the top half plane of the palette. Because human eyes are more sensitive to changes in the brightness than hue, this increasing contrast makes colormap_CD V2.0 good at distinguishing values that are away from zero.
-
colormap_CD V2.0 uses a different color palette compared with a regular HSV palette that have all colors fully saturated. Show both palette side by side, grid boxes in colormap_CD V2.0 palette (right) more distinguishable than HSV palette (left) for nearly every hue, especially when brightness is greater than 0.5.
- Color palette in colormap_CD V2.0 is achieved by decreasing the saturation for yellow , green, cyan, and magenta. These colors are brighter to human eyes, even when they have the same brightness value as red or blue. As a result, the four colors glare when fully saturated and become less distinguishable. In addition, when the saturation of these colors are decreased, the entire palette of colormap_CD V2.0 is more harmonic without particular part glaring. The benefit is that colormaps generated by colormap_CD V2.0 can be stared at a longer time.
Maintained by Duo Chan,Earth and Planetary Sciences, Harvard University.
Last update: 2018-08-14