1. 参考 www.52ocean.cn# [) } g: [& c7 Q9 |: K2 A
dc=hsv(18); % 18 colours are generated" F2 Q2 T- _* _& d. T1 H- b
x = 0:pi/100:2*pi;9 _5 B$ f& R4 y& d* R( r
hold on % you much write this before the plot
% ]5 X3 x* {) i2 \9 Xi=1;1 T0 @3 [) \) _6 k0 `: V
for d=0:0.2:2, % 11 lines in plot are taken
+ `- l/ O) {- @ plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)
, r7 T6 ^6 l& h5 b i=i+1;
. e! u0 V5 G. x5 [$ X. w: F" n# |5 tend/ ~2 m' f/ K/ ]! g n1 h3 w5 W1 G
4 \0 p- V/ w( Y2 Z5 d; m) S
6 S' P, z! ]6 X( J
4 u; }9 G; Q' L6 P2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
L- G5 Y# U, b' R2 {% k. s/ g) z2 x$ p* H. i) c' p1 K# h8 q
nlines=length(concentrations);cmap=hsv(nlines)
0 y: X/ x0 [- z& Bc=concentrations-min(concentrations);8 x: W( V! c9 s$ p
c=ceil(c/max(c)*nlines);
+ q, Y% V3 e, q/ [4 ], B9 ^, Vfor ii=1:nlines6 S$ A3 }9 L D; A* L7 b0 U2 x2 k% p
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:)), L, K- r% ]+ O E1 W% t: x4 a2 U
hold on;7 b- e3 Y4 V% F' [2 K5 ]
end
" z2 ^! x+ F- I2 d9 d4 Zhold off;, Y# J: @' |$ c1 [' I
. K/ P2 ]9 I+ ]. f7 e7 j& ^
+ W4 N+ m- G) k, H& X, g/ R* G
' J/ t, b: \" e; d& g% j* s9 l ' x J0 Q- z! k$ c2 Y) u( Z" L* D5 r
# f+ E$ z. T, ~ h7 C9 x 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |