1. 参考 www.52ocean.cn3 h+ Q! g( F3 W$ ?6 B' h& ?) s
dc=hsv(18); % 18 colours are generated5 d0 n, X/ Y8 A: G
x = 0:pi/100:2*pi;
2 r: I" f' k( a% O$ b4 O( }hold on % you much write this before the plot
# g# s/ e: F, z9 V/ qi=1;% V3 P8 M- `' V0 _
for d=0:0.2:2, % 11 lines in plot are taken
$ E" o, g- v1 C# y5 Z8 l plot(x,sin(x-d),'color',dc(i,,'linewidth',2)
( \; H1 @" o2 p; k( ~. T: \ w i=i+1;
6 {9 |+ R, W! d6 o1 B- r, n uend, n, R& E) P8 y4 N( z H& K1 l A
" b* } o9 g ~3 z. O, o% b2 ]
; N" H2 U" u8 x# q9 a0 t M
0 ?: ^6 X) C! ~0 n, j$ [+ s2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
/ g+ y7 c4 i$ T- [5 z$ D9 J
( p2 z5 {; j% m) ?- [nlines=length(concentrations);cmap=hsv(nlines)
, V3 V/ m' n. t5 T# h7 i! nc=concentrations-min(concentrations);
; l6 b8 }$ V+ p% o# c. A" hc=ceil(c/max(c)*nlines);
1 j( r' q( S7 s1 Gfor ii=1:nlines0 S/ D0 j. I+ `+ s3 J
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))+ U- J! _ t2 u0 I# S" C& y
hold on;' D* b( R: o y8 b8 g# ^8 w# U4 U
end
& ?0 @ T# w; ^2 `# b& }( P$ ]hold off;7 [6 }! @: @6 h7 c
. y& g3 f+ T9 M6 v2 ?& K% S, F7 R4 W0 G
, i4 K" I2 b" ?! E6 j8 w9 ?% m" r* G0 W
! ]) q+ _5 @& R. l5 A! C; d: i6 ~' `" R6 a, N# I- j
转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |