ColorBrewer: Attractive and Distinctive Colormaps

版本 3.2.5 (18.9 KB) 作者: Stephen23
The complete palette of ColorBrewer 2.0 colormaps. Simple selection by scheme name and map length.
26.7K 次下载
更新时间 2024/1/15
BREWERMAP provides all ColorBrewer 2.0 colorschemes for MATLAB, with simple selection by colormap length and colorscheme name. Alternatively the colorscheme name can be preselected, after which only the colormap length is required to define an output colormap.
BREWERMAP is compatible with all MATLAB functions that require a colormap. The function consists of just one M-file that provides all of the ColorBrewer 2.0 colorschemes (no mat file, no third party files, no file-clutter!). Downsampling or interpolation or repetition of the nodes occurs automatically, if required.
Examples
% New colors for the COLORMAP example:
S = load('spine.mat');
image(S.X)
colormap(brewermap([],"YlGnBu"))
% New colors for the SURF example:
[X,Y,Z] = peaks(30);
surfc(X,Y,Z)
colormap(brewermap([],'RdYlGn'))
axis([-3,3,-3,3,-10,5])
% New colors for the CONTOURCMAP example:
brewermap('PuOr'); % preselect the colorscheme.
load topo
load coast
figure
worldmap(topo, topolegend)
contourfm(topo, topolegend);
contourcmap('brewermap', 'Colorbar','on', 'Location','horizontal',...
'TitleString','Contour Intervals in Meters');
plotm(lat, long, 'k')
% Plot a scheme's RGB values:
rgbplot(brewermap(NaN, 'Blues')) % standard
rgbplot(brewermap(NaN,'-Blues')) % reversed
% View information about a colorscheme:
[~,num,typ] = brewermap(NaN,'Paired')
num = 12
typ = 'Qualitative'
% Multiline plot using matrices:
N = 6;
axes('ColorOrder',brewermap(N,'Pastel2'),'NextPlot','replacechildren')
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:
set(0,'DefaultAxesColorOrder',brewermap(NaN,'Accent'))
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
end
Bonus Functions
BREWERMAP_PLOT creates a figure which shows the nodes of all ColorBrewer colorschemes.
BREWERMAP_VIEW creates an interactive figure that allows selection of the colorscheme, and has two colorbars showing the colors of the colormap and the grayscale equivalent.
R2014b or later: BREWERMAP_VIEW can also update other axes' or figures' colormaps in real time, for example:
S = load('spine');
image(S.X)
brewermap_view(gca)
R2019b or later: BREWERMAP_VIEW can also update other axes' or figures' colororders in real time, by setting the 3rd input to TRUE:
plot(rand(5,7))
brewermap_view(gca,[],true)
Notes
The function BREWERMAP:
  • Consists of just one convenient M-file (no .mat files or file clutter).
  • Has no third-party file dependencies.
  • Has no special toolbox dependencies.
  • Requires just the standard ColorBrewer colorscheme name to select the colorscheme.
  • Accepts the colorscheme name as a string scalar or a character vector.
  • Supports all ColorBrewer colorschemes.
  • Outputs a MATLAB standard N-by-3 numeric RGB array.
  • Uses a default length the same as MATLAB's colormap functions.
  • 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 (unlike many on MATLAB File Exchange).
This product includes color specifications and designs developed by Cynthia Brewer (https://colorbrewer2.org). See the ColorBrewer website for further information about each colorscheme, colorblind suitability, licensing, and citations.

引用格式

Stephen23 (2024). ColorBrewer: Attractive and Distinctive Colormaps (https://github.com/DrosteEffect/BrewerMap/releases/tag/3.2.5), GitHub. 检索时间: .

MATLAB 版本兼容性
创建方式 R2010b
与 R2009a 及更高版本兼容
平台兼容性
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!

无法下载基于 GitHub 默认分支的版本

版本 已发布 发行说明
3.2.5

See release notes for this release on GitHub: https://github.com/DrosteEffect/BrewerMap/releases/tag/3.2.5

3.2.4

See release notes for this release on GitHub: https://github.com/DrosteEffect/BrewerMap/releases/tag/3.2.4

3.2.3

See release notes for this release on GitHub: https://github.com/DrosteEffect/BrewerMap/releases/tag/3.2.3

3.2.2

See release notes for this release on GitHub: https://github.com/DrosteEffect/BrewerMap/releases/tag/3.2.2

3.2.1

* update repository

3.2.0

* Default size to suit HG2.
* Accepts StringScalar and CharVector text input.
* Improve error messages.
* Simplify Mfile palette list.

3.1.0

* Add error IDs.
* Improve input checking.
* Split PLOT function.
* Improve interpolation accuracy.

3.0.0.2

* Update description.

3.0.0.1

* Add NaN input option.
* Simplfiy BREWERMAP_VIEW figure creation.

3.0.0.0

* Interpolate in Lab colorspace.

2.2.0.0

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

2.1.0.0

* Improve interpolation method.
* Update screenshot image.

2.0.0.0

* Improve interpolation method.

1.7.0.0

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

1.5.0.0

* Change to GitHub version, complete with Apache license.

1.4.0.0

- Downloadable as toolbox

1.3.0.0

- Simplify spreadsheet downloading instructions.

1.2.0.0

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

1.1.0.0

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

1.0.0.0

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库