1. 参考 www.52ocean.cn
, S) `/ C- ~% @/ T7 Q5 odc=hsv(18); % 18 colours are generated
$ s; H! z" J. tx = 0:pi/100:2*pi;
% t" N' I: ~. i6 X8 T' Jhold on % you much write this before the plot
! x/ t! O% {) U) P' A4 v7 x+ }i=1;
8 {1 x: ]0 @4 `* p6 c2 s# afor d=0:0.2:2, % 11 lines in plot are taken0 @7 `: D3 R9 ]' e9 w
plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)
. U3 i, h+ G* N/ A7 O i=i+1;
$ Y T: a/ l; @4 V/ I g0 B# |end
0 E7 A* b# A; h6 Q% o1 J; J; ~8 u4 |9 h- |+ `, V1 Y2 K1 Q; s b5 c
/ U5 V0 y6 ?% a
9 i2 a% h' v! a9 D' e2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
, c. c1 o1 U3 u* a! [
& X* m/ G, Z/ f8 g$ B( m$ }! anlines=length(concentrations);cmap=hsv(nlines)
1 ^/ i6 Y4 a; b* V3 i" \c=concentrations-min(concentrations);" g. m: u. a% p! H. ?1 C* K% N
c=ceil(c/max(c)*nlines);
4 Z& d: G% T9 u2 b1 _ zfor ii=1:nlines- y. ]- z8 A' U( K/ v, z& t
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
5 I5 z4 w+ S" G% I' V! Z {- h& m hold on;1 D$ e; j5 U% L+ j9 M; T
end
& ~: q2 a: k, X9 \; j* y x3 Rhold off;+ C( E1 t& s$ O- R- _7 O1 c
2 ^/ Z9 |: _. N7 z" @7 r/ c! d
+ O% K+ n$ L z" o5 I
; q, @1 |7 L! O" X: _0 |# b0 z/ u+ q8 B- }3 k1 u% p6 D
7 h0 L3 Q; j0 k- y7 J( c1 e
: M3 }1 J# w8 C {: p+ f 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |