1. 参考 www.52ocean.cn
- s( \" C4 G" z# H$ [9 I4 adc=hsv(18); % 18 colours are generated3 N/ W" p3 A4 k& E1 f) t. P- K% k3 i( L
x = 0:pi/100:2*pi;
: ?, t& C) m9 ~2 t! X$ dhold on % you much write this before the plot1 r, U! C+ h# n5 B/ y! X$ J6 S
i=1;% R* Z A: o" I' B2 R
for d=0:0.2:2, % 11 lines in plot are taken$ W1 g& I& J5 Q' \8 Y2 B& X& l
plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)
; s: e) s$ }4 Y2 S6 I- T i=i+1;
/ W- r% C* G8 L0 p6 A( ^' Y0 uend
; w, G6 |& k) p, E* |3 l/ R. `) x0 j$ Q
# Q8 Y1 c& k# z& g
0 Q: q5 ?9 L) H
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
8 d2 h7 f1 ?. E0 M
$ F$ e* x3 G1 j( W. i1 S* r; Knlines=length(concentrations);cmap=hsv(nlines)
) [# F' }: b: M7 N5 L0 v( oc=concentrations-min(concentrations);$ ^1 |2 m: H9 B! d
c=ceil(c/max(c)*nlines);
$ {1 `1 ?' J# m1 O" `# c2 a/ Y* ]for ii=1:nlines4 c4 R8 B4 w; e
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
# ^' F2 b* P1 o- a% p2 i5 d0 A hold on;$ [* \2 J9 K: N0 x( y) R8 J1 X
end% P3 y" x2 R4 ~1 c
hold off;* |9 i* Z) [; j
. a6 z& @$ ^0 s3 r* _( f8 B; G- a; r) j2 f
/ p: V$ W7 Q* o7 v5 n7 @
6 F9 \9 p% U7 D* m% S4 x3 d! j9 ^. l
, J4 f* {2 w( _5 e1 p( B- j3 \8 H& V& \' Y/ J
转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |