File Exchange

image thumbnail


version (122 KB) by Scott Lowe
Cynthia Brewer's ColorBrewer palettes, ported to MATLAB, with nice interpolation.


Updated 26 Jul 2016

From GitHub

View Version History

View license on GitHub

This package makes Cynthia Brewer's ColorBrewer schemes available in MATLAB, with a user-friendly interface.
The schemes can be interpolated to include more colours. By default, this is done using cubic interpolation in the almost perceptually uniform CIELAB colour space to prevent inflection points arising and distorting the scheme.

--- Requirements ---
To interpolate the colour schemes in CIELAB space, the FEX package COLORSPACE is required.
If you don't have a copy available, CBREWER2 will automatically prompt you to download it.

--- Features ---
* Supports all ColorBrewer 2.0 colour schemes.
* Has a simple interface, requiring just the colour scheme name and (optionally) number of colours to be specified.
* Can also accept a (redundant) type input, making the input format also compatible with that of CBREWER, so CBREWER2 serves as a drop-in replacement.
* Default number of colours is the same as the current colormap.
* Outputs a MATLAB standard N-by-3 numeric RGB array.
* Interpolates up to colormaps larger than the available colour scheme using a perceptually uniform colour space to prevent artefacts caused by interpolation in RGB space.
* Cyclically repeats qualitative colour schemes if more colours are requested than are available, mimicking the behaviour of the built-in LINES and FLAG qualitative colour maps.
* Is fully compliant with ColorBrewer's Apache license conditions.
* However it is NOT compatible with a minority of MATLAB functions which require a colormap to be provided as a string (eg: CONTOURCMAP). If you need this, please consult BREWERMAP (FEX: 45208) as a viable alternative.

There are several other ColorBrewer implementations available on MATLAB File Exchange, with some overlap between their feature sets. However none of the others have all the features which CBREWER2 possesses. In particular the perceptually uniform interpolation is important if you need more than 12 colours in your colormap.

--- Notes ---
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.

You can report bugs and suggest new features on GitHub:

Cite As

Scott Lowe (2021). cbrewer2 (, GitHub. Retrieved .

Comments and Ratings (5)

Bryce Grier

Jessica Schrouff

Stephen Cobeldick

@Scott Lowe: thanks for rephrasing the description. I will change mine as well in a few days (have a few things to do first).

Table: You might like to experiment with the publish feature (the markup includes a table syntax). These HTML files are also displayed on FEX when you upload a submission with the "html" subdirectory. Unfortunately, I think this does not work for GitHub submissions.

Scott Lowe

Hi, Stephen Cobeldick.

I decided to include an addendum in the same style as yours to help the users understand the different features between the different ColorBrewer packages on FEX. I even mentioned the feature CBREWER2 which does not have and directed them to your package if they are in need of it!

In the interests of consistency (with the end-user in mind) I copied one of the points you made verbatim and changed the wording of 4 others to make them clearer. The other 4 points are entirely different because of the differences between our packages.

My intention is not to imply that my package is the only with each of these features (though it is the only one with all of these features). Surely this is the case for your description also, since BREWERMAP wasn't the only package that "Supports all ColorBrewer colorschemes." and "Outputs a MATLAB standard N-by-3 numeric RGB array." before I uploaded CBREWER2?

Saying that, I can rephrase the description to make it clearer if necessary. I think a comparison table, would be best - if it can be done sensibly without a monospaced font. Additionally, I should say that any problem in the description of CBREWER2 is also present in that of BREWERMAP, so I daresay it also needs to be updated.

Stephen Cobeldick

@Scott Lowe: Well, it is said that "Imitation is the sincerest form of flattery". In this case you copied most of your "Addendum" points directly from my FEX submission (45208, which you also link to). However doing so was a bit illogical: if my submission already stated that it is (was!) the only submission that fulfilled most of these points (map size, license conditions, simple usage, etc), how then do you explain copying my points and claiming that "Compared to other ColorBrewer submissions available on MATLAB File Exchange, CBREWER2:" is the only submission that fulfills those points?

You copied my points, and now are using them to claim that your submission is the only one to fulfill those very points that I wrote!

Please consider revising your description to be more accurate.

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!