1. 参考 www.52ocean.cn& P: t4 U6 u, z$ ]$ \
dc=hsv(18); % 18 colours are generated( g9 P. A, `! p B
x = 0:pi/100:2*pi;2 j" q7 v* ?+ G6 M/ f) _) K
hold on % you much write this before the plot
9 a- s- K* }( z4 E' o% f; ^; \' Ti=1;
) K+ P g) P5 J$ xfor d=0:0.2:2, % 11 lines in plot are taken
3 R* G8 q+ N5 |# _* l plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)( L4 M- }7 h$ U* I5 U( {' }
i=i+1;
. L5 U7 o5 g, wend/ V5 v; D. A/ {% N J/ Z) z" V
& P' E3 a* N9 C" T9 u# I |( f- |& D- j# |" [% k+ x) d
' k) W' t& V; G2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data: e4 g% K$ f4 u
1 ~4 k ^, @ \2 m. \7 Z1 D. T q
nlines=length(concentrations);cmap=hsv(nlines)
7 t7 l, Y. a# `" yc=concentrations-min(concentrations);" m8 z1 P( Q! a6 E, G+ A# o, {( U
c=ceil(c/max(c)*nlines);
2 r* B6 t, J- A% f5 _for ii=1:nlines; g: ^* |" g$ o
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))0 i& z& I$ J0 F/ F8 s( _# L0 l' N
hold on;
+ m0 H1 J$ u# H; T$ W. |end2 ~3 Q4 q* c; @/ I0 \9 V: j4 p
hold off;4 @: J8 G& ^" e- M* v
) ~" O0 [ p: ~& N( S! k2 A. e
7 c, b# g; X, `: K
}2 l5 D. V$ R% _5 V4 W5 F" y7 @
) H+ K( Q! S+ k
4 t# v$ T. ~8 L
+ V: C3 h7 d4 _2 B( D$ x# I( f 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |