1. 参考 www.52ocean.cn
& D$ f0 w9 ]0 q2 }0 sdc=hsv(18); % 18 colours are generated1 B2 j- d n9 Q6 J9 u" I0 X" [6 b. [# T
x = 0:pi/100:2*pi;
( n$ u6 v4 }& V- s) j; q2 hhold on % you much write this before the plot; r9 @' L' T. k: g7 _
i=1;# u6 D2 H2 r' @
for d=0:0.2:2, % 11 lines in plot are taken3 e+ L6 o: }& V' U
plot(x,sin(x-d),'color',dc(i,,'linewidth',2)
4 v' J) C- P# H- H9 v3 j. v+ x i=i+1;- c# k) R+ [* \0 v8 F
end
0 N' _5 Y, i! m; B4 K |7 C5 ? R; I
* ~1 B5 m, |7 i3 C
, ] F g: k0 r8 n6 r% S6 J$ _7 {( @
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data0 T, p. a" [, L" o+ H0 j
5 k7 _* y" {# @; d }nlines=length(concentrations);cmap=hsv(nlines)5 V$ N( T- C6 j. U
c=concentrations-min(concentrations);
9 X: b; x, X& M6 F; zc=ceil(c/max(c)*nlines);! m' b( J; ` c) e- m
for ii=1:nlines6 N% L3 O( s. D4 j2 V! a {
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))# k* c; U% }3 G' T3 H( n* v- L
hold on;
+ N, C6 q& X/ |9 v) Wend* Z- I/ n6 J. g2 l7 b. D& V& F8 }) w
hold off;
; K9 M; R! ^8 [% ^! Z6 V* U6 a' l @
3 c4 J4 \0 |) d* D
' Y$ U; h, R0 g# l' _1 Z) j
, v1 J8 f' B5 k& w9 k: I( H . ^1 ^' ^: e* a$ g6 k
4 y6 _7 W( I1 ^* `8 x
转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |