4.71429

4.7 | 7 ratings Rate this file 15 downloads (last 30 days) File Size: 6.07 KB File ID: #7144

usercolormap

by Yo Fukushima

 

14 Mar 2005 (Updated 18 Mar 2005)

No BSD License  

usercolormap lets you create your own colormap in a simple way. Intensity scale can be respected.

Download Now | Watch this File

File Information
Description

USERCOLORMAP(COLOR1,COLOR2,COLOR3,...) creates a colormap with colors specified by 1x3 vectors (COLOR1, COLOR2, COLOR3...).
 
When the number of input colors are three for example, the function linearly interpolates every column of a 3x3 matrix [COLOR1;COLOR2;COLOR3] to 256 values, which is to be used as an input to COLORMAP. It means that colors between those you specified change gradually.
 
If you put a number (>0) as the last input argument (USERCOLORMAP(...,NUM)), then the intensity scaling is respected by automatically adjusting colors, in such a way that the first color be the darkest (or lightest) and the last be the lightest (or darkest). This is useful when figures have to be printed out or photocopied in grayscale.
 
When using this option, n-th intensity I(n) is expressed by I(n) = I(1) + (I(256)-I(1))*((n-1)/255)^NUM. When NUM = 1, then the scaling is linear (as in colormap(gray)). 1.2 can be a good compromise between color map and intensity scale. You can check how it looks in intensity (black and white) by exporting a figure to a black/white eps format.
 
You can also create an m-script like
%%%%%%
function C = mycolor
C = usercolormap([0 0 0],[1 0 0],[1 1 1]);

%%%%%%
and call this colormap by 'colormap(mycolor)'.

(Example 1)
color1 = [1 0 0];
color2 = [1 1 1];
color3 = [0 0 1];
figure;
colormap(usercolormap(color1,color2,color3)),colorbar;
 
(Example 2)
color1 = [0 0 0];
color2 = [1 0 0];
color3 = [0.2 0.2 1];
color4 = [1 1 0];
color5 = [1 1 1];
figure;
C = usercolormap(color1,color2,color3,color4,color5,1);
colormap(C),colorbar;

Acknowledgements
This submission has inspired the following:
COLORMAP and COLORBAR utilities (Sep 2009)
MATLAB release MATLAB 5.3.1 (R11.1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
11 Apr 2005 Pierre Tinard  
11 Oct 2005 Megha Jain

The program was really good but what should i do to exploit its full functionality

22 Nov 2005 Tom Williams

Very useful, especially the intensity interpolation figure. How about including the ability to generate a colormap of arbitrary size?

06 Nov 2006 Lupita Marquez

Good, i improved it by setting the input as a matriz with 3 columns, and with the size of the map as a varargin (default 256).

09 Nov 2006 Carlos Adrián Vargas Aguilera

Great, and agree with Lupita (nice name)!

12 Dec 2006 Matthias Moosmann

Perfect! Exactly what I was looking for!
Thanks!

26 Feb 2008 Fred De Masi

Great! Cheers!

Please login to add a comment or rating.
Updates
18 Mar 2005

An option is added, Description is updated.

Tag Activity for this File
Tag Applied By Date/Time
annotation Yo Fukushima 22 Oct 2008 07:43:21
vectors Yo Fukushima 22 Oct 2008 07:43:22
colormap Yo Fukushima 22 Oct 2008 07:43:22
colors Yo Fukushima 22 Oct 2008 07:43:22
customization Yo Fukushima 22 Oct 2008 07:43:22
graphics Yo Fukushima 22 Oct 2008 07:43:22
plot annotation Yo Fukushima 22 Oct 2008 07:43:22
plot Yo Fukushima 22 Oct 2008 07:43:22
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com