1. 参考 www.52ocean.cn
, Q& q/ U- N" z8 F! Zdc=hsv(18); % 18 colours are generated
" [" ]1 U; E5 [- {, \x = 0:pi/100:2*pi;
; U5 g9 A$ Z: J) u! x Whold on % you much write this before the plot/ u2 w6 n: Z8 s# m# p
i=1;
. N5 u a6 X I, O( C3 F, _2 wfor d=0:0.2:2, % 11 lines in plot are taken
+ \, r! b9 \. x8 A plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)+ X1 n8 C6 S7 j* K( I( j( _
i=i+1;
/ @3 B* j* v7 @$ Eend! V, D' L. `$ A5 p) G! v% ]
' H$ v( W- e9 i, k; o0 a+ R' v- w* y1 F& m
0 H5 N/ @1 M5 E2 {) x1 h2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data) B" C( m. z0 Z* R- U
) z* S6 s: G4 \& Knlines=length(concentrations);cmap=hsv(nlines)/ W5 s9 _ A3 A3 L1 h2 u
c=concentrations-min(concentrations);
, p) v1 s' k& ?) l, N" N, [! t, @c=ceil(c/max(c)*nlines);' \- t9 G# V6 Y9 h8 i
for ii=1:nlines9 t3 l! e" M# C8 j7 M
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
+ V4 n0 Q0 Z3 H, u* O7 K2 }/ o1 R: R hold on;
+ R) t+ ]$ V) cend% Q! R% }. V5 g0 T
hold off;5 n2 A; F: e% J% |, _) G$ V& z
8 P c2 h% B/ Q) R
: B; ^5 u/ O4 f7 b) Z4 y7 b
9 a7 w! p% x, j, j- ]2 |( t9 ]
5 T" T5 C7 Q! ] C1 H2 g- s. x
" B6 O0 I7 x% ]* C1 B5 g, G/ K$ s
7 B. s- C o: U+ Q5 f$ n 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |