-
Notifications
You must be signed in to change notification settings - Fork 0
/
brewermap_plot.m
52 lines (51 loc) · 1.33 KB
/
brewermap_plot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function brewermap_plot()
% Simple plot of all ColorBrewer colorscheme nodes in one figure.
%
% (c) 2014-2022 Stephen Cobeldick
%
%%% Syntax:
% brewermap_plot()
%
% See also BREWERMAP BREWERMAP_VIEW CUBEHELIX MAXDISTCOLOR
% LBMAP PARULA LINES RGBPLOT COLORMAP COLORBAR PLOT PLOT3 AXES SET
[mcs,nmn,pyt] = brewermap('list');
%
persistent cbh axh
%
xmx = max(nmn);
ymx = numel(pyt);
%
if ishghandle(cbh)
figure(cbh);
delete(axh);
else
cbh = figure('HandleVisibility','callback', 'IntegerHandle','off',...
'NumberTitle','off', 'Name',mfilename,'Color','white',...
'MenuBar','figure', 'Toolbar','none', 'Tag',mfilename);
set(cbh,'Units','pixels')
pos = get(cbh,'Position');
pos(1:2) = pos(1:2) - 123;
pos(3:4) = max(pos(3:4),[842,532]);
set(cbh,'Position',pos)
end
%
axh = axes('Parent',cbh, 'Color','none',...
'XTick',0:xmx, 'YTick',0.5:ymx, 'YTickLabel',mcs, 'YDir','reverse');
title(axh,'ColorBrewer Color Schemes (brewermap.m)', 'Interpreter','none')
xlabel(axh,'Scheme Nodes')
ylabel(axh,'Scheme Name')
axf = get(axh,'FontName');
%
for y = 1:ymx
N = nmn(y);
M = brewermap(N,mcs{y});
for x = 1:N
patch([x-1,x-1,x,x],[y-1,y,y,y-1],1, 'FaceColor',M(x,:), 'Parent',axh)
end
text(xmx+0.1,y-0.5,pyt{y}, 'Parent',axh, 'FontName',axf)
end
%
drawnow()
%
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%brewermap_plot