1. 参考 www.52ocean.cn& E) J3 J; m! g( f+ \) Y
dc=hsv(18); % 18 colours are generated
9 l8 n8 |8 \# a3 l- Z+ Dx = 0:pi/100:2*pi;, Y. X1 S! _+ j
hold on % you much write this before the plot7 W, s2 f1 l! s' h% D
i=1;
- x/ ~( `: y" s( `! Sfor d=0:0.2:2, % 11 lines in plot are taken
3 ^" m7 u! ]2 ]2 c$ `$ E; I plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)7 K( J+ z5 d/ M) W* D. ]: L1 d
i=i+1;5 u& Z$ t; I! Z4 d/ c% z# ~. a
end. C0 v9 S! e! I: w5 f/ ^
& r" M0 x+ y4 U9 h0 `. f1 u! W R G$ R4 t0 @. j( j' {# k& q
2 g; o' X: t# s0 r$ H& I6 B2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data& }6 b/ B7 K( S% n* h
Y- b. S. Q" i8 w( F% _) s
nlines=length(concentrations);cmap=hsv(nlines): i1 v8 d" n- @5 f6 Z1 N
c=concentrations-min(concentrations);, U9 _( }3 }" M4 P, J
c=ceil(c/max(c)*nlines);
/ `$ ]4 q9 a4 f4 s0 K* t2 L/ p7 ^ Hfor ii=1:nlines2 L) `: l6 w+ R/ r+ M$ }% J2 i: T. J
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))& y p6 o! ] ]$ D
hold on;
# a7 T: o5 B" g. N& l3 Lend
6 n' C8 e" |% w7 V9 m2 d5 Ehold off;9 b/ i9 c( ]' G. u( \6 m1 x
# K8 M9 r8 k2 e4 n& T! h4 U% Z+ S; S; C2 r, y+ L8 I1 v
4 Q- r- L% K! x1 W3 H6 |8 t
0 F, t* ~9 j: J4 C" ~$ ]) M, a % Q" W% G$ V7 Z3 D/ I7 H& u8 p
( \) w- {" J+ V4 Y6 C) Q 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |