1. 参考 www.52ocean.cn8 ?) V$ y3 f, `! b
dc=hsv(18); % 18 colours are generated1 a% c" }0 d( r/ A" b4 H( P$ L
x = 0:pi/100:2*pi;
. C9 B) q! p5 H, }4 O4 Whold on % you much write this before the plot- d+ B& L) q# N5 R
i=1;
7 ?( Y& U$ A5 L& Yfor d=0:0.2:2, % 11 lines in plot are taken
7 N+ S' b$ l8 Z2 E; d9 p plot(x,sin(x-d),'color',dc(i,,'linewidth',2)7 m' x4 I7 u+ ^
i=i+1;
2 }: u4 Z! k. w* Q* hend7 b/ X* | e' @$ O; p; ]
6 e( S0 [+ C+ \
* t1 d' r H& J! x5 B( H: i7 F0 v. l+ r* z. l
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
' _6 U; j3 i7 ^$ w" C" \
' O1 V+ c. Y# F x* }! wnlines=length(concentrations);cmap=hsv(nlines)- H: t; V6 m; \
c=concentrations-min(concentrations);( m0 c r: N3 u5 |# z' Y3 {- [) B
c=ceil(c/max(c)*nlines);2 P6 z/ L* E$ ]7 |% z9 x3 f7 @
for ii=1:nlines
% S0 u, g3 j, S) V plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:)), d9 R) F* R5 \9 a. ?8 O
hold on;# a/ _) |! J7 R6 }, A% W" {: O2 ]
end
; o6 E# |5 E" @5 q: [hold off;; S: ~6 s: D$ g; j& Y4 I
& P) A3 p1 T5 M! @* t: D9 s Y" H! P7 O( ?. g
! {5 j* S2 Y% V6 @9 b1 T
% c4 d* k, `" s' b1 U
/ {2 |6 H: S+ ~' J# X2 R+ g/ v
h6 B' M% y1 S i- T1 X' P 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |