1. 参考 www.52ocean.cn
4 y* i. T2 r- {7 `2 vdc=hsv(18); % 18 colours are generated
4 H2 J s+ o; Ex = 0:pi/100:2*pi;
8 `2 B0 X1 ?% _' p5 s/ Ohold on % you much write this before the plot- P4 [* y% x8 x; U
i=1;
6 t5 B: t, v$ h4 G7 c4 f0 Efor d=0:0.2:2, % 11 lines in plot are taken
& Z+ V5 w3 q% t% \! p plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)3 m! J. v7 \! d# N+ f+ D
i=i+1;
& Q. o% C4 R0 ] b' Nend. A6 I2 ?% }9 y) T/ c0 \
3 J8 m, `4 N0 n$ G; z8 S
$ [) k0 q/ {6 A# |' S8 u* g
1 v- I$ O. ^8 c2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
x! c. t2 ]* d1 y s; U
5 t5 q5 w7 U, j' n0 Ynlines=length(concentrations);cmap=hsv(nlines)4 I3 a- L+ w+ }6 k# u" C1 r# r
c=concentrations-min(concentrations);: k0 h1 o% j* y. p: n' N
c=ceil(c/max(c)*nlines);
9 Z& I) b) e6 i7 Z0 d6 W2 V; tfor ii=1:nlines
0 E6 d# W, l: ]. x1 \+ o, D plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))9 O U6 z, _& O9 U
hold on;
3 I }9 s d9 l) send9 i# A+ r" K, {2 d0 x! q3 M, K
hold off;
. [8 f7 N( Y( ^8 J& A; e
. h' R* p* X/ C' d+ K' |# |' N1 G" e' ]* |. G6 p8 ~
5 x0 l* W6 a' ? W2 I, R, y: G+ V* }: O5 T7 p( j
f4 V E% x* `5 m) n1 u, f
1 M3 u3 R" ~, P8 N% b+ B
转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |