Get from Ico-github-logo

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

» Watch video

Highlights from
ColorBrewer: Attractive and Distinctive Colormaps

  • brewermap(N,scheme)
    The complete selection of ColorBrewer colorschemes (RGB colormaps).
  • brewermap_view(N,scheme)
    An interactive figure for ColorBrewer colormap selection. With demo!
  • View all files
4.8 | 13 ratings Rate this file 217 Downloads (last 30 days) File Size: 42 KB File ID: #45208 Version: 3.0
image thumbnail

ColorBrewer: Attractive and Distinctive Colormaps



22 Jan 2014 (Updated )

The complete palette of ColorBrewer colormaps. Simple selection by scheme name and map length.

| Watch this File

File Information

BREWERMAP provides the ColorBrewer colorschemes, especially intended for mapping and plots with attractive, distinguishable colors.

BREWERMAP is very simple to use: only the the colormap length and the colorscheme name are needed to select and define an output colormap. The colorscheme can be preselected by the user, after which only the colormap length is required to define an output colormap.

BREWERMAP can be used as a drop-in replacement for the inbuilt colormap functions and it is compatible with all MATLAB functions that require a colormap. BREWERMAP consists of just one M-file that provides all of the ColorBrewer colorschemes (no file-clutter!). Downsampling or interpolation of the nodes occurs automatically (if required). The interpolation is performed in the Lab colorspace. As an option, the colormap can be returned reversed.

### Bonus Function ###

BREWERMAP_VIEW creates an interactive figure that allows selection of the colorscheme, and that contains two colorbars showing colors of the colormap and the grayscale equivalent. It also allows adjustment of other axes' or figures' colormaps, for example:
load spine

### Examples ###

% Plot a scheme's RGB values:
rgbplot(brewermap(9,'Blues')) % standard
rgbplot(brewermap(9,'*Blues')) % reversed

% View information about a colorscheme:
[~,num,typ] = brewermap(0,'Paired')
num = 12
typ = 'Qualitative'

% Multiline plot using matrices:
N = 6;
X = linspace(0,pi*3,1000);
Y = bsxfun(@(x,n)n*sin(x+2*n*pi/N), X.', 1:N);
plot(X,Y, 'linewidth',4)

% Multiline plot in a loop:
N = 6;
X = linspace(0,pi*3,1000);
Y = bsxfun(@(x,n)n*sin(x+2*n*pi/N), X.', 1:N);
for n = 1:N
plot(X(:),Y(:,n), 'linewidth',4);
hold all

% New colors for the COLORMAP example:
load spine

% New colors for the SURF example:
[X,Y,Z] = peaks(30);

% New colors for the CONTOURCMAP example:
brewermap('PuOr'); % preselect the colorscheme.
load topo
load coast
worldmap(topo, topolegend)
contourfm(topo, topolegend);
contourcmap('brewermap', 'Colorbar','on', 'Location','horizontal',...
'TitleString','Contour Intervals in Meters');
plotm(lat, long, 'k')

### Note ###

Note that the function BREWERMAP:
* Consists of just one convenient M-file (no .mat files or file clutter).
* No third-party file dependencies.
* Interpolates in the Lab colorspace.
* Requires just the standard ColorBrewer scheme name to select the colorscheme.
* Supports all ColorBrewer colorschemes.
* Outputs a MATLAB standard N-by-3 numeric RGB array.
* Default length is the standard MATLAB default colormap length (same length as the current colormap).
* Is compatible with all MATLAB functions that use colormaps (eg: CONTOURCMAP).
* Includes the option to reverse the colormap color sequence.
* Does not break ColorBrewer's Apache license conditions!

This product includes color specifications and designs developed by Cynthia Brewer ( See the ColorBrewer website for further information about each colorscheme, colorblind suitability, licensing, and citations. Note that BREWERMAP is the only submission on MATLAB File Exchange providing ColorBrewer colorschemes without breaking the ColorBrewer license conditions!


Light Bartlein Color Maps, Vivid Colormap, Cold Colormap, Red Blue Colormap, Haxby Color Map, Bipolar Colormap, Perceptually Improved Colormaps, Generate Maximally Perceptually Distinct Colors, Matlab Colormaps As Seen By Color Blind Users, Stoplight, Othercolor, Color Gradient: Generate Custom Linear Colormaps, Colormaps Compatible With Red Green Color Perception Deficiencies, Cbrewer : Colorbrewer Schemes For Matlab, Polarmap: Polarized Colormap, Build Custom Colormaps, Custom Colormap, Beautiful And Distinguishable Line Colors + Colormap, Cubehelix Colormaps: Beautiful, Distinct, Versatile!, Intuitive Rgb Color Values From Xkcd, Rgbmap Color Maps, Convert Between Rgb And Color Names, Color Gray, Sc Powerful Image Rendering, Color Palette Tables (.Cpt) For Matlab, Cmap2pal Convert Matlab Colormap To Binary .Pal Format, Hslcolormap, Perceptually Uniform Colormaps, Jetwhite(Colours), and Jet White inspired this file.

This file inspired Paruly, Newcolorbar: Multiple Colormaps In The Same Axes, Cubehelix Colormaps: Beautiful, Distinct, Versatile!, Jetwhite(Colours), Cbrewer2, Squink(Colors,Gamma), Cyclic Color Map, Cmocean Perceptually Uniform Colormaps, and Convert Between Rgb And Color Names.

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (17)
18 Nov 2016 CKanellas

F**cing beautiful. Great job!!!

21 Jun 2016 Kaiguang

24 May 2016 Jonathan Sakkos

15 Mar 2016 David E. Horsley

14 Jan 2016 Eric Dauenhauer

Very intuitive, great preset color schemes, and easy to scale to any size data set.

04 Jan 2016 E. Cheynet

02 Oct 2015 COE

COE (view profile)

02 Sep 2015 cheng joylin

08 Jun 2015 Rong Yu

23 Mar 2015 Chad Greene

Chad Greene (view profile)

This function is excellent, easy to use, and works perfectly, right out of the box. Thanks for sharing, Stephen.

05 Oct 2014 Stephen Cobeldick

M S : Thank you for your feedback. I am glad that you found my submission easy to use, as the convoluted usage of other ColorBrewer submissions on MATLAB File Exchange was one of the main motivators to write this. I intended that usage of this function should be as much like the standard colormap functions as was reasonable and feasible.

Your suggestions and observations about the unsuitability of the ColorBrewer schemes for colorblind users are very true. As you point out, the white middle color is unclear in many situations, and not just for readers with vision deficiencies.

However I did not create the ColorBrewer schemes (credit goes to Cynthia Brewer for this), nor do I make any claims about their suitability for a particular purpose, other than to say that they are "attractive, distinguishable colors". Any claims about the suitability for any particular purpose are solely those of Cynthia Brewer, for whom I am not responsible. The sole purpose of this submission is to provide the best access to the ColorBrewer colorschemes for MATLAB File Exchange users.

You might like to consider using the colormapeditor:

Writing a colorblind-friendly maximally distant colormap generator would be quite interesting, but this is a clearly a very different task to this simple porting of Cynthia Brewer's existing colorscheme data. For a start, each of protanopia, deuteranopia, tritanopia, protanomaly, deuteranomaly, and tritanomaly would require a completely different set of permitted colors. If you are interested, contact me and we could develop this together.

Comment only
02 Oct 2014 M S

M S (view profile)

Pros: supports colorblind palette, which is desperately needed for matlab visualization. Easy to use.

Cons: poor for any plotting purpose; it is not designed for any visualization where there's a background color. For example, for a 'divergent', 'colorblind friendly' scheme, the middle color is always white or off white, which is obviously terrible for plots with a white background.

I wish there were a way to combine another FEX submission, distinguishable_colors--which not only arranges maximally distant colors, but takes into account background color--with colorblind friendly implementation.

18 Aug 2014 Stephen Cobeldick

You are completely correct that it is possible to redistribute the ColorBrewer colorschemes: in fact this is explicitly permitted by the Apache license that they are released under.

Note though the very first license condition for redistributing ColorBrewer says that "Redistributions as source code must retain the above copyright notice, this list of conditions and the following disclaimer". So when someone redistributes it, it must be accompanied by the same Apache license*. However MATLAB File Exchange does not permit any license to be used other than the BSD license:
"For consistency, the BSD license will be the standard for the File Exchange".

So we reach a minor impasse: to redistribute ColorBrewer requires an Apache license, to submit to MATLAB FEX requires a BSD license. Snap. I could distribute a complete version of this function under an Apache license, but not on MATLAB FEX.

Several other submissions have simply ignored ColorBrewer's Apache license, but hopefully FEX does not turn into an exchange of any licensed code that happens to take peoples fancy.

* For an example of this, scroll down to the bottom of the excel spreadsheets that are available from

Comment only
18 Aug 2014 Nicholas

Nicholas (view profile)

Nice job, but not sure why you state you cannot redistribute the colormaps since the website suggests that you can, assuming you meet the requirements. It does, however, specifically state you cannot call the software "ColorBrewer"...


Comment only
14 Aug 2014 Michael Chan

Michael Chan (view profile)

Beautiful work, Stephen.

09 Aug 2014 John D'Errico

John D'Errico (view profile)

A very nice submission to upgrade your figures for good viewing by all viewers.

Excellent help and examples for use. I found the web site interesting too.

05 Aug 2014 Stephen Cobeldick

I just noticed that Internet Explorer 8 does not display the hyperlink 'downloads' on the ColorBrewer website:
The complete list of hyperlinks above the main image should be 'how to use', 'updates', 'downloads' and 'credits'. This displays correctly on the current versions of Firefox and Chrome.

If using IE the required Excel spreadsheet can be navigated using the following hyperlinks:
'updates' -> 'Excel files with all of the ColorBrewer RGB numbers' -> 'ColorBrewer_all_schemes_RGBonly3.XLS'.

Or simply download from the following URL:

Comment only
06 Feb 2014 1.1

- Add third output: colorscheme type as a string.
- Better input checking and error messages.

07 Aug 2014 1.2

- Allow case-insensitive scheme selection.
- Simplify downsampling indexing.

08 Aug 2014 1.3

- Simplify spreadsheet downloading instructions.

03 Nov 2014 1.4

- Downloadable as toolbox

04 Jan 2015 1.6

- Edit online blurb..

18 Aug 2015 1.5

* Change to GitHub version, complete with Apache license.

03 Nov 2015 2.0

* Improve interpolation method.

03 Nov 2015 1.7

- Re-insert that disappearing newline at after the first paragraph. Why does this happen, MATLAB?

03 Nov 2015 2.1

* Update screenshot image.

03 Nov 2015 2.1

* Improve interpolation method.

06 Dec 2015 2.2

* Include "brewermap_view.m" for interactive colormap viewing and selection.

19 Mar 2016 2.2

* Update FEX blurb.

22 Feb 2017 3.0

* Interpolate in Lab colorspace.

Contact us