1. 参考 www.52ocean.cn
& [& @' C. b5 t, d3 S$ X1 `; Ddc=hsv(18); % 18 colours are generated& ]) Y* `& R8 q. z" o' ^- L
x = 0:pi/100:2*pi;5 m7 A* C* K' C6 i5 _2 N
hold on % you much write this before the plot
1 P* F4 U' `3 x: n& |" Oi=1;
K! T$ c' ^5 ^- |9 ] c9 \+ \) wfor d=0:0.2:2, % 11 lines in plot are taken
4 t7 c/ [& ]+ G! S plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)# y" n. U0 c0 c
i=i+1;: E+ G7 q. a5 W" Q1 Z! }
end
s' m: [/ G, ]7 \: N% Z% |5 Q0 l) t; H B
3 z) |/ G- o$ o7 Z. @
- [2 d7 ?5 z/ C& k
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
5 ?4 c( H! w/ m; W
% s6 \7 K! L0 T1 r# C% Y) Lnlines=length(concentrations);cmap=hsv(nlines)1 w$ c/ i! {! J
c=concentrations-min(concentrations);
7 @, M* u+ v5 Y4 rc=ceil(c/max(c)*nlines);
$ I& Q7 d9 s# ffor ii=1:nlines0 F8 [% u) |' o4 w
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))7 X) u8 B! R, T# _) n
hold on;: B2 M3 `3 w) U7 g
end9 T4 B4 \! g5 ^: F
hold off;
6 M2 J) i0 l* P8 E6 l* D# P) }: [$ G0 L
# c# W7 y, |1 Z( t* H; j7 G$ j
* I% E- B6 D3 v. j0 x8 T
9 ~5 x! ^$ A+ C: ]+ e; M+ a: C
0 U6 `; d. u3 B
/ \, f Y% j- H8 ?+ G% s& ^ 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |