1. 参考 www.52ocean.cn
$ M4 J8 d& {, p# q" `* [dc=hsv(18); % 18 colours are generated
/ t" V# R2 N# m) W8 ux = 0:pi/100:2*pi;
) Q j- G: K) W( |hold on % you much write this before the plot
; |' N) o2 ]: k \! i [8 Ei=1;, O- T6 \3 L K. {' a3 f: j2 `
for d=0:0.2:2, % 11 lines in plot are taken
! t" Q6 I0 S: w5 Q plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)
( Q% A1 H7 b0 F; C i=i+1;
2 f8 |+ y; G& c; Aend2 D( ~9 w5 {5 A
& m' @% U5 r0 }% W. Z( N: `4 M* u* Z+ l! H7 b$ t. Y
/ w% S: V H% x$ Y4 i) U
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
- i0 o( q3 b3 R+ i: a; M' b5 d G; `$ ?1 ]# S3 a7 h8 M2 q9 a
nlines=length(concentrations);cmap=hsv(nlines)
. H! v6 A1 c7 Z6 T/ n Dc=concentrations-min(concentrations);# n! G0 c4 S+ k& ?' Q) C
c=ceil(c/max(c)*nlines);. m6 R* V0 s. P* D
for ii=1:nlines, M3 }: Y* M# e3 ?1 l: H
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
) [9 k0 Z& b3 X" d; p hold on;5 y7 a& _! h/ F* H9 @ @
end
. |3 o0 p7 V0 U8 M# \4 ]hold off;) X4 F. r2 a2 _8 C5 _' q9 H( c! J2 U
% G( W; W& n( a, e& @
& D* h, a1 Y& I j
( c. M9 d/ _/ C2 G! x9 k: \3 y
3 w) i7 ]& m2 w: A3 g k- F 1 L- n- Y; ]1 [6 a2 n1 l; R; c
+ V' K0 }+ m5 m x" r4 R' z
转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |