1. 参考 www.52ocean.cn
{5 E. w; o4 C1 Y8 l0 Edc=hsv(18); % 18 colours are generated
8 \: O" V8 W0 N7 H$ ox = 0:pi/100:2*pi;
1 `5 B7 m( e( M! y/ t" s, Thold on % you much write this before the plot
: U" v7 G" z- t% x. ti=1;& q x* L c/ w6 ^: l! j3 I! `
for d=0:0.2:2, % 11 lines in plot are taken
$ m5 l; J/ n4 D" }* e5 ~' I plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)1 @% b2 m' J, d6 U( F
i=i+1;2 P0 ]/ t, [( V
end
8 r# }1 c3 o/ y* T1 p; `. ]& e! Z: T* _9 j
3 |7 Q; ^$ o4 N8 \7 y3 {8 m, z4 l9 j0 y9 [0 A1 W9 d0 f/ G5 s+ c7 P, m
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
) {: D3 O2 z+ ^# d
* a2 J6 i: d8 T* r+ Z$ b Znlines=length(concentrations);cmap=hsv(nlines)) \1 r! Z; L9 p# M( M/ c' N- ~; K
c=concentrations-min(concentrations);3 g0 W \: O8 D" ~, p6 c8 g
c=ceil(c/max(c)*nlines);( y/ ?: i- t7 X
for ii=1:nlines
, ?& W/ ^+ r6 D# B; q' X4 f plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))0 `; o" e! c4 M. I: t4 E
hold on;( G4 r! }8 l& i. E
end
9 C* l! C$ B9 h3 Lhold off;
) W* W, B5 H0 s
& G9 `$ H3 `: X' z9 S: P( a
1 E3 Q/ |1 j, y/ |, M6 `# E" s) u& f6 q5 y* |5 @
7 o7 W9 T* i' T% x9 Z2 n" T! V' x2 R # W3 ]* ?7 ~- p: O1 `3 t5 |) ^$ C
e9 o l+ L# a4 x" s5 B- U& ^ 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |