How to Split the Matlab Jet Color Table to RGB
MATLAB is a software package produced by MathWorks that enables users to build upon a large library of functions for technical analysis and presentation. In the production of color figures, MATLAB provides a set of colormaps to convert between data values and colors in figures. Accessing the color values in a MATLAB colormap is simple to do through both the user interface and command line.
Instructions
-
-
1
Create a jet color table with a specified number of values using the jet() function with an integer input. The default colormap for MATLAB is jet(64). The my_cmap variable is a 64x3 array containing red, green, blue color values.
my_cmap = jet(64);
my_other_cmap = jet(128); -
2
Access the RGB values of a particular value in the jet colormap by accessing the stored colormap array. Accessing my_cmap(32,:) returns the RGB value [0.5 1.0 0.5]. MATLAB RGB color values are floating point numbers ranging between 0 and 1.0.
-
-
3
Edit the specifics of the stored colormap by manipulating the RGB values of the stored colormap array.
-
4
Apply the altered colormap using the colormap() function. The first example applies the colormap to the current figure while the second example targets a specific graph by passing the axis handle.
colormap(my_cmap);
colormap(axes_handle, my_cmap); -
5
Edit the currently selected colormap by calling the colormapeditor() function from the MATLAB command line.
-
1
Tips & Warnings
The names of built-in MATLAB colormaps are jet, HSV, hot, cool, spring, summer, autumn, winter, gray, bone, copper, pink and lines.
References
- Photo Credit Thinkstock Images/Comstock/Getty Images