Debian Codegraph @

tests/inputs/issues/528/matlab_line_colors.m

raw
1 %{
2 https://www.mathworks.com/matlabcentral/fileexchange/42673-beautiful-and-distinguishable-line-colors-colormap
3 %}
4
5 % LINE COLORS
6 N=6;
7 X = linspace(0,pi*3,1000);
8 Y = bsxfun(@(x,n)sin(x+2*n*pi/N), X.', 1:N);
9 C = linspecer(N);
10 axes('NextPlot','replacechildren', 'ColorOrder',C);
11 plot(X,Y,'linewidth',5)
12 ylim([-1.1 1.1]);
13
14 %{
15 SIMPLER LINE COLOR EXAMPLE
16 %}
17 N = 6; X = linspace(0,pi*3,1000);
18 C = linspecer(N)
19 hold off;
20 for ii=1:N
21 Y = sin(X+2*ii*pi/N);
22 plot(X,Y,'color',C(ii,:),'linewidth',3);
23 hold on;
24 end
25
26 %{
27 COLORMAP EXAMPLE
28 %}
29 A = rand(15);
30 figure; imagesc(A); % default colormap
31 figure; imagesc(A); colormap(linspecer); % linspecer colormap