1. 参考 www.52ocean.cn, r1 I' r8 G4 r& A& ^; `
dc=hsv(18); % 18 colours are generated
5 N; Q `3 \* S: x" kx = 0:pi/100:2*pi;
0 K) p* P0 O3 k" N, j V, t% Shold on % you much write this before the plot
4 O; ]# p5 }$ z# n8 v: Ci=1;+ Y1 ?& O& ?4 F9 e/ p( c% n
for d=0:0.2:2, % 11 lines in plot are taken
! e$ k0 g. B, W4 ]$ g. Z) y plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)
' Y2 u( F( h; j i=i+1;
$ D! i* o: I8 `: fend& f/ s$ ^# }- T* u& K6 Q: x a
0 K: |$ E6 ?- ]) ]5 V
9 D, g6 y9 s2 o/ s+ P8 Q3 B$ L9 O& k5 R4 `) K. v9 s& r
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data% [* `8 m" y j# h+ U0 M8 i5 J q
9 J6 V1 D% k% U
nlines=length(concentrations);cmap=hsv(nlines)
" P0 ^4 I/ U& W' k) O& x; {+ Yc=concentrations-min(concentrations);0 Q) s2 A2 \8 v @3 I; v. h
c=ceil(c/max(c)*nlines);& V; k* I1 q3 ]3 M, }2 a7 [# E. }
for ii=1:nlines
( Q$ u) ^. g* | plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:)): f! K- c7 R7 H/ K5 Y1 b; u
hold on;
. Y5 M5 o1 s( ~4 M& Eend- S c! X$ d. z! s
hold off;& g8 K% ]& p2 b, Q) A9 }% p
8 F6 \7 q) s, x: D. d2 E8 x2 R" {) e. ~" A7 ]3 n5 ]
1 t2 R7 J* [3 u, j
" `7 K& ~3 r! S3 }
- W/ [7 }/ ^: U4 A; } ?! F7 L( |0 |/ x/ G. g
转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |