1. 参考 www.52ocean.cn
7 E% a7 H- r, R2 ]; W( Zdc=hsv(18); % 18 colours are generated0 x: z- _/ e9 o/ l0 y, Y
x = 0:pi/100:2*pi;
- g; n4 R- f" {4 I- t2 qhold on % you much write this before the plot
* c1 S) \5 P& |5 O' c9 ni=1;9 V. c) e+ H' D5 E
for d=0:0.2:2, % 11 lines in plot are taken
' i. h3 t9 p6 F1 {! W$ x plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)
# o4 e+ D1 R2 g3 m3 g9 `3 p2 p$ } i=i+1;- T& h( W H- d/ D/ P! v3 ]
end
9 K9 ^+ h+ K; j8 f7 T% C& y! ]
+ U4 n0 t9 e, T% q' A8 Q# z: ~* p: T9 i7 {8 C" n/ E0 b
' s5 g1 h: I5 U w8 o$ ~2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data' m+ I" F; d8 j: v
; @( v" a3 _4 n" G! \8 }nlines=length(concentrations);cmap=hsv(nlines)
5 I0 J7 ^3 E: N8 b1 O- X9 K9 xc=concentrations-min(concentrations);" [4 ]8 P. |0 f: {7 `: C& v5 k- B
c=ceil(c/max(c)*nlines);
9 m5 _0 B4 |' ?# qfor ii=1:nlines
* G/ @" M3 X% X6 W+ Z; Z) d plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))0 h8 F- K/ q# J
hold on;
; w4 }& T2 q9 W( b& }& k% Jend
$ b1 `' ?" e; {7 B, c" }9 rhold off;
[/ k7 L& q0 ?1 x. S+ i# V& D! s# j& s7 T* }
$ x/ E/ r7 b5 Z6 Y4 K V5 P. D
2 N( K+ F( Q1 F x" c; g# [# b' O& c
( w3 ?! F. e$ e. o" V0 ^6 \
3 m- `' x$ m8 D/ |# E 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |