1. 参考 www.52ocean.cn/ w+ A4 ~" t j3 `8 v y2 N0 \: o
dc=hsv(18); % 18 colours are generated* ]3 t1 D) T* P8 c
x = 0:pi/100:2*pi;6 ~- T# b- P, r* k7 A# B. z
hold on % you much write this before the plot0 ~2 N" \" i A1 `; b2 b+ j
i=1;
! G: Z* s6 Q+ G0 ffor d=0:0.2:2, % 11 lines in plot are taken
3 h3 `, d0 V' r# A+ ~ E plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)+ _6 S" _5 h# s j7 L" N) Y' z
i=i+1;! C% t0 t& h9 g
end
b% V* n; ^8 c6 e j' t! w1 U4 A1 n: q# w8 ? ]- X ?1 z% @
+ u% Y! R9 s4 e/ [# U% E8 G# t" u* `
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
$ T+ ]& r6 Y5 u2 r& s! I# ]! _4 }: X6 _. R# X; N. W
nlines=length(concentrations);cmap=hsv(nlines); _/ _5 f. N7 E9 j5 B7 _
c=concentrations-min(concentrations);$ c: D! i, p. L' ]) i2 y
c=ceil(c/max(c)*nlines);/ q4 i7 S1 ?* e; Z4 M1 I) h1 S0 @; `
for ii=1:nlines) W+ o; V+ u- t% }
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
# P# d0 z4 ]7 e; E" f hold on;& } ~) }# O( o) l+ E7 {& D
end6 W5 Z* ^- e/ ?* E/ V h
hold off;
2 m1 |/ c& w- I( D: v( K1 U
; w ^( e+ f6 [0 r
5 j/ |. w' C* }# ?3 d
" r1 W( p) I# P8 m" W& L" Q1 N. Y. ~
' P, H1 P+ Y! Q/ h$ y4 B E. {+ K4 [1 N, x9 A
转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |