Code covered by the BSD License  

Highlights from
custom colormap

4.25

4.2 | 4 ratings Rate this file 22 Downloads (last 30 days) File Size: 2.33 KB File ID: #36501
image thumbnail

custom colormap

by

 

02 May 2012 (Updated )

sets the colormap according to monotonically increasing user defined ranges

| Watch this File

File Information
Description

This function is useful if you don't want to use the linear scaled colormap that are the default in Matlab.
   
USAGE:
         CUSTOMCMAP(cbar_labels,user_cmap,minMaxValues)
                    
% INPUT:
% cbar_labels - Vector (n x 1) of monotonically increasing ranges of data
% user_cmap - Matrix ((n-1) x 3) of colormap you want to see
% minMaxValues - Vector (2 x 1) of minimum and maximum value of data
% that is plotted
%
%
% EXAMPLES:
data = rand(10,10);
minVal = min(min(data));
maxVal = max(max(data));
image(data,'CDataMapping','scaled');
cbar_labels = [0 0.12 0.2 0.3 0.5 0.6 0.75 0.8 1]; % user defined ranges
user_cmap = jet(8); % user defined colormap
customcmap(cbar_labels,user_cmap,[minVal maxVal])

Bug and comments are welcome.

Acknowledgements

This file inspired Valcolor.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
26 Sep 2014 Holger Hoffmann

Great Function. Love it.

The only issue is, when making maps with contourf() with EdgeColor on and changing subsequently the colors with CUSTOMCMAP(), the isolines are wrong (still the old ones). However, that's not a real issue / not the job of CUSTOMCMAP()

24 May 2013 mohammed

It does not seems to compatible to subplot.

19 Feb 2013 Alexandr Troshchanovskii

.

17 Jul 2012 Zhi Liu  
17 Jul 2012 Zhi Liu

How should I adjust it so that I can show gradients between labels?

06 Jun 2012 Lukas Chvatal  
Updates
19 Jun 2012

Minor bug fixed.

Contact us