Code covered by the BSD License  

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Build custom colormaps

4.7 | 3 ratings Rate this file 18 Downloads (last 30 days) File Size: 2.05 KB File ID: #40318 Version: 1.0
image thumbnail

Build custom colormaps


M Sohrabinia (view profile)


Buillds any sequence of colormaps based on wrgbcmyk colors

| Watch this File

File Information

This function can be used to build your own custom colormaps. Imagine if you want to display rainfall distribution map. You want a colormap which ideally brings rainfall in mind, which is not achieved by colormaps such as winter, cool or jet and such. A gradient of white to blue will do the
task, but you might also use a more complex gradient (such as white+blue+red or colors='wbr'). This function can be use to build any colormap using main colors rgbcmyk. In image processing, w (white) can be used as the first color so that in the output, the background (usually with 0 values) appears white. In the example of rainfall map, 'wb' will produce a rainfall density map where the background (if its DN values are 0) will appear as white.

 colors: string (char) of color codes, any sequence of rgbcmywk
 representing different colors (such as 'b' for blue) is acceptable. If a
 gradient of white to blue is needed, colors would be 'wb'; a rainbow of
 white+blue+red+green would be 'wbrg'.

%try the output cmap:
imshow(im), colorbar
colormap(cmap) %will use the output colormap


This file inspired Rgbmap Color Maps, Color Brewer: Attractive And Distinctive Colormaps, and Cubehelix Colormaps: Beautiful, Distinct, Versatile!.

MATLAB release MATLAB 7.13 (R2011b)
Other requirements Not sure if you require mapping toolbox
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
30 Oct 2014 Rafael Madrid  
11 Oct 2013 Ricardo

Thanks a lot! I was looking for this kind of function, you have just made my life easier!

27 Sep 2013 M Sohrabinia

M Sohrabinia (view profile)

@Alfredo: thanks for your comment, you mean the range of the output? such a 0 to 1?

Comment only
13 Sep 2013 Alfredo

Very Good! It would be nice to have also the possibility to specify the desired size of the output colormap.

Contact us