1. 参考 www.52ocean.cn2 E3 ~, i6 q3 b- v2 b7 f% m
dc=hsv(18); % 18 colours are generated! n- I: J7 I$ y9 g8 `* g, q
x = 0:pi/100:2*pi;& Y( @! g: N1 |7 J, Q
hold on % you much write this before the plot' A. m* X5 r. e3 L
i=1;- O6 z' {4 }* F5 {) D/ |
for d=0:0.2:2, % 11 lines in plot are taken
" ]1 o/ X" h* q6 \3 w plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)0 P/ X3 P; _! `& K: W! i5 B
i=i+1;' X* m+ V; [ e. F0 g
end
! {4 e$ O A( u/ N8 q( r6 ~4 d4 P& S2 _ n2 a, M" g9 ~
: @3 F0 e% g7 S& n( e, C
/ R5 G6 ^; f; T, H5 K6 F/ {
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data2 @; Z+ t7 J& V* g' S. K4 W' d
* z/ y2 \& M. N# hnlines=length(concentrations);cmap=hsv(nlines)
6 X+ n+ x( ^& i& yc=concentrations-min(concentrations);
! I7 a o9 [9 t7 Mc=ceil(c/max(c)*nlines);; a& z+ E0 }1 w, Z! C" I9 U
for ii=1:nlines9 Y7 ~8 P; s9 E! Z u& n, V4 o8 n
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))' G* R/ ^) j/ R, x( D% V7 T7 N
hold on;5 K- e3 F# }9 j( F8 p9 b
end
# {5 _2 T6 G" |5 w5 mhold off;
5 z! g, o- z* W9 G) J. e l/ P+ Z5 F6 V. x- P0 Y! k
" B8 K/ k! a7 `" L8 ]- z) h+ L9 G
' b! a( Y B& l' @9 i3 Z
$ n- `; |+ X* z6 X, z: g , a: s8 z. P3 }" k1 @
# M, k; [: f+ t4 M 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |