1. 参考 www.52ocean.cn
. [2 h( O; [0 Q8 ndc=hsv(18); % 18 colours are generated9 q* |( O5 i/ H/ K( K
x = 0:pi/100:2*pi;2 L. h, [8 Q8 P
hold on % you much write this before the plot
" t/ ?* `: i* E2 B# \i=1;5 q1 S5 C1 c# @
for d=0:0.2:2, % 11 lines in plot are taken
}& O! v( I! a3 a& ?) T9 I plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)- X% w' F7 w* S& m( Z% F% w% L7 D
i=i+1;
5 M0 W9 l9 e% Oend; W" A7 u) J0 ? L8 V# ~, |
Q7 O4 O0 k- u( W6 e1 U0 z* T3 Q9 ?
4 E# a j) L5 V5 m7 t4 v2 v) E* y% N# s" M0 {& d7 C
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
, K4 J: j: [* P7 ^$ D% h8 Q; h- J8 M: j1 A( M
nlines=length(concentrations);cmap=hsv(nlines)
/ O( d" O# B! M) W4 V# zc=concentrations-min(concentrations);
4 I) W4 T) h1 y" O* ?c=ceil(c/max(c)*nlines);
# t- W, d4 k7 d$ x4 {for ii=1:nlines
8 y- ]+ a1 r& j/ D5 ~+ C plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))) K2 C- a" k' S8 j" {$ ?+ @3 q
hold on;
; ?, J/ M( x) E k& Vend
" _: x7 S3 R- L [hold off;
- R7 f+ j' _% E7 S! A
, ?0 \; r4 I9 E- @3 R3 D( q
8 e- l( e0 b5 l
( O$ f! \9 @' c f) f. \& F; c
1 k. X2 b( s d; m5 C ) u0 P& k K9 l( p% W) K
9 G% L3 `% N; S# `) C' E) {3 f 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |