1. 参考 www.52ocean.cn+ \4 k F9 B* C; U
dc=hsv(18); % 18 colours are generated+ |' d: a3 p+ u
x = 0:pi/100:2*pi;
; D+ ]; M# B9 K* L5 thold on % you much write this before the plot
2 U9 T% }- R* V: _! n7 {i=1;
5 B# S9 m* O7 C0 y0 Cfor d=0:0.2:2, % 11 lines in plot are taken; x; z x% R- Q% ^: M2 I1 {) O( k
plot(x,sin(x-d),'color',dc(i, ,'linewidth',2)0 R) d) d2 O8 V$ t o" b3 \6 @- ^, p
i=i+1;
6 Y. A5 u0 @- W* T$ R$ [end
, ]- w3 z9 M- L! @' E) P+ R8 m7 v( ~- d
! |4 [* r) o# P$ r5 L* { j# {, }1 @. `' D5 L
% ^. h) m' U# T% t+ H' n
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
5 M3 T0 E0 d3 d+ i; V; t. e9 i
. d T. P. @; t7 Y" Hnlines=length(concentrations);cmap=hsv(nlines)3 A, |6 {+ S' P: |, l) i+ {
c=concentrations-min(concentrations);8 }1 O) i$ ]9 I( G V- J2 o
c=ceil(c/max(c)*nlines);
# I \7 q, X3 ~- H6 t! y; \& Jfor ii=1:nlines7 W7 z6 ]5 \" l; D3 E7 H
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
" N- T* t+ _6 Y& h3 Q hold on;
( Y( E+ y9 T! J: M$ u% s7 J: fend
3 [5 c( e* f d' V6 |hold off;/ K: I1 E$ e" M
) K# ]$ j5 F/ q: b! f
5 f6 `( F- }$ ~; Y B8 R5 }- r0 t9 r, F, m; a
9 \! R6 \' e1 l. `: f
- b/ f; ^, f: O* v( J2 O7 Q/ k _/ F5 a: K# C
转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |