1. 参考 www.52ocean.cn" g1 t6 |- h5 Y9 J# O: K) b9 c* }
dc=hsv(18); % 18 colours are generated; y; t' S# | H
x = 0:pi/100:2*pi;
# Z- s( R* z& n: m! e" k' thold on % you much write this before the plot
3 T/ J+ H. s" p5 V! ii=1;
) H6 {% B }3 E* Lfor d=0:0.2:2, % 11 lines in plot are taken8 Y6 g) @ V6 o2 e1 U7 o
plot(x,sin(x-d),'color',dc(i, ,'linewidth',2), l% U9 ?: |; t3 }2 }# \/ L
i=i+1;
+ [% {5 b- I* a& p0 r# C% q- Q9 [end
. ^3 n+ H" B1 P7 |* q/ L
$ d' H" c% q2 q
8 ~9 y7 P6 J: a3 u7 @1 ~0 |8 _, e- C M
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
/ h$ o9 Z$ \# T: F9 w
+ {1 j A1 ^) v4 C9 ^' Mnlines=length(concentrations);cmap=hsv(nlines)' h5 G1 w B5 S6 I
c=concentrations-min(concentrations);
& |4 Z/ t. |& g! J1 ~2 C6 u; h M* wc=ceil(c/max(c)*nlines);+ H6 V n1 |/ s' V
for ii=1:nlines
* O1 z6 p. e6 H3 J3 ]2 Q& P% e2 V/ ~ plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
% _/ b) S; i$ Y& t' k hold on;; b/ o& ]7 g- }+ F4 f. ?" P. w6 |
end
) U* f* c5 Q7 p7 j* s2 D7 R) _' `hold off;6 e; P) ~% q( [# B A6 H9 }! A
0 C6 e1 \! T( \- E6 [; x* C: I$ \. G9 |# L: L
6 J3 G9 C1 N' O
+ y: o7 W; a. ]( k* y' c2 s5 n
( k e0 c/ m9 v
7 t5 G9 W' M# S B2 r 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |