1. 参考 www.52ocean.cn3 o0 w% J' i5 I1 M
dc=hsv(18); % 18 colours are generated. Y$ D' C3 b2 P1 a3 X
x = 0:pi/100:2*pi;* a- r( B$ r. _) [
hold on % you much write this before the plot2 R1 o/ C, }( t- a( k" N
i=1;- w- @$ K6 L2 P/ h/ [
for d=0:0.2:2, % 11 lines in plot are taken6 l1 a( W4 C, p$ ^( ?( L: Y. H9 @+ }
plot(x,sin(x-d),'color',dc(i, ,'linewidth',2); B" ?7 E4 U: ^' V9 @
i=i+1;. s; C1 c* l% k d
end
+ h/ k7 c4 S8 D S4 r W. B- p
8 P+ }( `3 O4 Q7 m) l" M6 E/ a( ?3 |, `
5 r5 P: [6 P) {4 @0 Z7 F3 F, j) A7 L
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
' t$ f7 Z" t b3 l, }9 m$ c. M+ z/ L; r+ `
nlines=length(concentrations);cmap=hsv(nlines)
. z% J: C1 T. g5 ic=concentrations-min(concentrations);1 B- U% t- d' Y" C* W
c=ceil(c/max(c)*nlines);
. E _! g( M( V7 z- x; i3 Mfor ii=1:nlines$ \. v0 r2 w/ [' M
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))' a, S' S% w q( a; V9 H' d
hold on;
1 e9 D! N/ l- E2 B6 D+ x9 iend
6 A! C' @7 ]/ _# q: v8 t6 Uhold off;
8 m% \# P% J4 b8 q7 R8 v( {- q5 s; f; w
# ?3 @% h' m; N# c8 Z4 b
8 i8 ]/ X! q! g. h& J! H! \
; v' o7 s& J* X* J8 b0 V3 j
, A7 C6 L- c, I' C
3 j+ t& r# j, c! D5 @& y B2 [ 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |