1. 参考 www.52ocean.cn7 X3 U" ^/ Y0 c! j9 ~- v
dc=hsv(18); % 18 colours are generated. M- L1 d+ f& W
x = 0:pi/100:2*pi;
, |8 j- E% h. H% O2 Khold on % you much write this before the plot! d7 a U2 m# s
i=1;3 F! Y) ^/ v; {7 O6 A* P7 }% _3 i
for d=0:0.2:2, % 11 lines in plot are taken/ K) x9 V5 z- \* B% V, a$ A
plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)2 z2 x6 N. v# Z. }6 Q, O
i=i+1;6 U0 F, j& _5 E- a; M% U* Q6 g
end/ F g) ]; c/ m& p7 b
& G3 k8 I# I# Z1 C7 J0 a
- R- K( i% K! k1 t7 |$ ~
4 w6 d. k$ S# H& @% S2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
+ Y1 D$ D% U1 L3 r# @( }+ L" Q/ M' @" O7 p0 S2 a8 y1 i3 ?1 X
nlines=length(concentrations);cmap=hsv(nlines)
1 h) R" f" @4 ac=concentrations-min(concentrations);1 U, G! P5 v5 L6 q
c=ceil(c/max(c)*nlines);+ g8 r" d5 z [ Y, q5 w
for ii=1:nlines
, K' O9 V7 p5 B. F& W$ r plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
7 G( n; Z9 \, O hold on;1 c' }4 t& v( i! j6 l
end
7 V& G" t* \0 dhold off;$ u0 T$ w& O% V( I
8 Q9 ^+ t5 V( F& [
: z) R6 U* m' e2 Y% q
. u4 c# O: U+ {) {( W0 V% J8 j+ d4 }- s9 M7 ?- g& @
+ c1 n, j3 L. I, D1 G, {/ m
8 K! a' \- x$ V 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |