Skip to content

Beautiful and clearly distinguishable color palettes for Matlab users.

Notifications You must be signed in to change notification settings

duochanatharvard/colormap_CD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

colormap_CD V2.0

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!


Quick start

If you run:

col = r2bCD;

You get a nice blue-to-red colormap: new-repository-button


Why should I use this toolbox?

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. new-repository-button

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. new-repository-button

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. new-repository-button

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. new-repository-button

drawing


How to use colormap_CD V2.0

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.

b2rCD

This function generate double-hue colormap. Run:

col = r2bCD;

new-repository-button You can use argmument "num" to choose number of colors in individual hues. Foe example:

col = r2bCD(9);

new-repository-button There is also a "name" argument, which allows to take value of "precip" and returns a colormap for precipitation anomalies:

col = r2bCD(6,'precip');

new-repository-button

g2rCD

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;

new-repository-button 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');

new-repository-button

col = g2rCD(6,'g2b');

new-repository-button

jetCD

This function generate rainbow-like colormap. Run:

col = jetCD;

new-repository-button The "name" argument allows you to do:

col = jetCD(6,'season');

new-repository-button 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.

hotCD

This function generate single-hue colormap. Run:

col = hotCD;

new-repository-button The "name" argument allows you to go through every major hue:

col = hotCD(6,'y');

new-repository-button

col = hotCD(6,'g');

new-repository-button

col = hotCD(6,'c');

new-repository-button

col = hotCD(6,'b');

new-repository-button

col = hotCD(6,'m');

new-repository-button

col = hotCD(6,'gry');

new-repository-button

detailCD

This function is usually called during data exploration period, which generates colormaps that distinguish between the minor changes in the value.

col = detailCD;

new-repository-button The "name" argument allows you to show details of both positive and negative values.

col = detailCD(6,'double');

new-repository-button Note that you can always use the following command to reverse the order of colors.

col = flipud(col);

new-repository-button


Q: What if none of the above colormaps is what I want?

A: You need to call the colormap_CD.m function in colormap_CD V2.0 to customize your own colormap.


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:

drawing

Input arguments of colormap_CD.m

RGB_out = colormap_CD(hue,brt,gry,num)

Hue

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);

new-repository-button 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);

new-repository-button

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);

new-repository-button

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);

new-repository-button

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);

new-repository-button In this example, m = 1, so only one hue is allowed in each segment of the colormap.


Brt

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);

new-repository-button


Gry

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],:);

new-repository-button


Num

Number of colors in each hue.


Why colormap_CD V2.0 works better

Two reasons make colormap_CD V2.0 works better than default Matlab colormaps:

  1. 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.

  2. 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.

new-repository-button

  • 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

About

Beautiful and clearly distinguishable color palettes for Matlab users.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages