1. 参考 www.52ocean.cn$ I- i5 l: I% `' ?5 w4 M
dc=hsv(18); % 18 colours are generated B7 s& Q* X! t" x o1 h
x = 0:pi/100:2*pi;
+ k- V2 L; q9 Y' w9 T8 f7 Dhold on % you much write this before the plot
$ l5 D/ n. a* X/ S3 K2 @i=1;
5 c+ ?) I) R4 q: X. a& Ufor d=0:0.2:2, % 11 lines in plot are taken+ F- {# k1 S% F% ^' c% ~# v
plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)
; L: @9 ~9 g( y i=i+1;( m. A r" H" B+ _. C8 T' C- `
end
( A6 n& U: N, k: e4 L" O
( D7 U( W) n i& b
2 w& E4 X9 j8 z( M
" b: U2 k8 V1 A7 \& _# \/ m5 J$ q2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data) l7 S" }3 m7 U$ R+ O
% g8 y3 w7 t, v, e5 }) A+ {. Nnlines=length(concentrations);cmap=hsv(nlines)
5 b( S- f. m" @7 qc=concentrations-min(concentrations);5 |4 ^" B7 r, v1 ]) a& a7 R$ }- J
c=ceil(c/max(c)*nlines);
' m1 ~! C5 N2 {4 Dfor ii=1:nlines
# x6 W+ x7 _# y7 x9 e plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))4 G- i' }$ G) M
hold on;9 j, V" ?3 A6 y; t [! O
end& S1 A& f3 z# l' K: H3 g6 ^5 |
hold off;
8 I/ @, W- u+ L# }; X7 E
- V! J3 B F2 F! j( e. ]
) Z4 \- Z; O1 u. Y3 w) B- C+ ?0 [ \# f
+ d* n, A# S8 \) d) V. ^$ n
A; W1 D" R. u! c1 t! [
0 g% E3 w: Q+ k0 b! x/ @# m" W 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |