1. 参考 www.52ocean.cn
2 w [# t0 N# k4 Cdc=hsv(18); % 18 colours are generated" g6 D; f7 o2 N) `& S
x = 0:pi/100:2*pi;
6 G2 o8 m. }* p l( d0 T. xhold on % you much write this before the plot
9 k" H* b6 _, k, e8 [i=1;
8 ~& K0 o4 K: ^8 Xfor d=0:0.2:2, % 11 lines in plot are taken4 F W" m/ t5 H' U# W0 {
plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)% b$ y- N$ Z# r8 A' i+ A
i=i+1;
- ~6 K- s& [) n& L+ z4 u1 `end
, `8 i m- U. H1 R' K5 T; i0 n6 F+ }5 h: y2 W* s4 p8 T
6 H v/ u) |6 y+ D6 u8 J* U L0 l/ W8 i: {' s" ~) L1 Q# }
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
* ^/ s) T4 o4 M
$ ~4 n2 T6 o" p" m9 Unlines=length(concentrations);cmap=hsv(nlines)
/ D% W2 w) s' ?/ cc=concentrations-min(concentrations);, t i+ u! f; s5 R2 }
c=ceil(c/max(c)*nlines);4 {2 B3 P* |# y
for ii=1:nlines- ~' z% K. |- W. X% l$ @7 h9 m0 B+ [
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
3 q( L5 ^3 K+ _- G2 _2 f6 | hold on;6 }4 B# R% D0 t$ ? O
end
3 e! I: t' Q, X3 E7 l6 qhold off;" s$ u4 T9 e* \- X
/ Z8 s& K! d1 k( R! i6 O# p5 o9 W0 R* Z2 a2 z H
, ?0 l @3 O, {8 k
; e# Y& U; s3 l: {" n
# L- S, A4 r; h, _' w- D9 T
! f2 }+ \4 i$ E! |, p) f# R 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |