1. 参考 www.52ocean.cn" a! b* y: h" }9 F N
dc=hsv(18); % 18 colours are generated' ]* B3 T7 m1 U8 J
x = 0:pi/100:2*pi;6 J! Q b. ]7 ? W; |- p
hold on % you much write this before the plot) t0 P' t) ^7 Q5 H1 N0 @3 M$ Q
i=1;
+ ~, V6 o5 {* t9 N1 sfor d=0:0.2:2, % 11 lines in plot are taken
0 `$ z4 Q) A6 ]' r" u; ^ plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)" ~) w( s% c, r+ ^% L1 k$ t
i=i+1;7 |- A5 m$ ?1 a+ S7 B3 ~9 B
end
0 u- ^3 l2 w& P/ p9 E% g4 B
) d9 ?+ r- \" Y2 k3 w7 p- U% l$ q' a( A% \# Q6 T0 T" z
. _8 u4 {: @# t( y" R" ?. \2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data0 m6 }1 r0 V+ O- R+ w
! J" l! }( N9 J( M- q
nlines=length(concentrations);cmap=hsv(nlines)
6 H% d5 T5 {" {' J& f( i1 sc=concentrations-min(concentrations);3 s( t3 D5 y& v9 l3 f1 s
c=ceil(c/max(c)*nlines);4 |( ]/ f0 G0 @3 P; _
for ii=1:nlines
# N7 ~$ Q- L" l `* U& v plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))! `/ e0 _8 t/ A% l
hold on;
* P3 Y' {- |9 Hend
% T# R: G* O* X0 j: y9 T3 m- Thold off;
w" p( I! K2 a3 q1 {6 W
, D" `. R2 k0 R R1 f3 D4 [) P( I5 B3 t2 d, c
/ S" q9 y3 T- ^( a6 E' X
( M+ W/ D* C* p! C/ P " L+ @9 _ s! z9 M2 E2 Y) m+ l l* F
. x; c7 d7 G# Y2 [' v! s& l
转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |