1. 参考 www.52ocean.cn( l8 e* b, t3 d8 X$ \( I f
dc=hsv(18); % 18 colours are generated
) ^3 g5 E9 T0 N7 `" Cx = 0:pi/100:2*pi;
! l& U }; Q7 O5 Z$ i3 ^5 _hold on % you much write this before the plot* S3 j* O) Z: c& n
i=1;
8 a, d/ Z9 o; Tfor d=0:0.2:2, % 11 lines in plot are taken/ K" S3 k. A8 |* @% [2 Y* S
plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)- y, Y" P% k0 z2 R4 z
i=i+1;* z$ M+ c' S+ ?& a9 x$ @6 [( r' @ {
end. |( |. R5 _1 w. C
- E9 W- A) x: m' E/ L1 g, ~, W% [' S1 x* f% t. G9 X5 }
; B# E% p- Z" Q+ _" P6 T
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data& j4 ~: `; s" S4 Q, k+ u
. m. c2 D1 y9 O- [3 c
nlines=length(concentrations);cmap=hsv(nlines)
; l* W% R0 r* M- Q% N" [c=concentrations-min(concentrations);, ~! T; r- S; p5 R' b6 H: t
c=ceil(c/max(c)*nlines);, ]8 [7 ?3 n% g" D \7 n+ F4 ]
for ii=1:nlines# n" v T% T; L% [- @) j
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:)) P. Y+ i/ y0 s7 G# N# Z# c
hold on;
3 T" |1 W( u! Z: N. \( kend
- B5 Q2 m/ C% o4 u& Qhold off;8 F& U" c& O5 g$ v
4 o/ ?5 j4 u+ g- S- H
4 e5 r) b7 i' L( U, u
- K8 ], q+ c4 `+ n, W6 G: ?: e+ @9 Q
4 F4 T* y( |2 T4 h: n0 m& x$ B1 U7 z- z& m : N4 _* P/ H7 p9 n7 A) X
, p- T- H# I3 {2 M: e t 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |