1. 参考 www.52ocean.cn
$ w4 [7 g ]# t8 B% Odc=hsv(18); % 18 colours are generated
" I1 i4 S+ P- G) ex = 0:pi/100:2*pi;
1 U' f% M4 x& I; ^hold on % you much write this before the plot( ^5 V- q. f! N# h) ]
i=1;
7 k8 @8 f- c/ M+ l; D* h% J, ^for d=0:0.2:2, % 11 lines in plot are taken& w% x+ _6 O- k9 j9 F/ L
plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)' R/ n p. o4 I* B, M. c
i=i+1;
; d* |) x) U6 r+ `4 }end) H8 J+ t m9 D" _. b8 @6 O
$ n" L1 t1 y0 F% C2 k
" F- ` t! q+ z/ i d6 ^
0 I* G( |+ E3 c" L, ~
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data1 }: d8 X' K- k i$ x
1 y |+ x. y8 a. m7 a+ Bnlines=length(concentrations);cmap=hsv(nlines)4 W9 R" a* `/ s- K/ e
c=concentrations-min(concentrations);
& }! f0 k# `8 @; C L% O: L* g) \c=ceil(c/max(c)*nlines);
2 N% }( }/ e1 T) X3 r. i. xfor ii=1:nlines* ?: d- p: v" F. V2 N U
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
7 m( X: B- p) e& L1 S0 A/ T hold on;; |% @9 C. S0 T r, }' T' W
end- S; c* Z0 E7 d: \' G% K7 G
hold off;7 _1 D+ R0 q) ~1 d4 W3 V+ C
2 a. |) C2 R' |* D" v8 G5 ^; f6 F* ]( ?2 ^9 ]' r% H4 N. ~
/ I8 T) {6 O/ z) a
) D& O" T" y+ X - T2 L1 o! b1 N. e6 s7 |& u
# P3 E2 q/ S/ e( { 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |