【Matlab】有关plot画颜色渐变曲线的设置

[复制链接]
1. 参考 www.52ocean.cn( Q4 }2 ~1 e; g8 C: x9 ~
dc=hsv(18);           % 18 colours are generated. Q  k( s# W4 }$ }7 E' F/ `% ]: g, }
x = 0:pi/100:2*pi;' L8 b* M1 C& \; [7 n
hold on                  % you much write this before the plot9 t9 h$ j( r) A& q
i=1;
$ w( m$ K5 j5 A* ~+ L* rfor d=0:0.2:2,   % 11 lines in plot are taken9 I$ a/ V2 q6 J4 R# S: O6 \
  plot(x,sin(x-d),'color',dc(i,,'linewidth',2)
8 B+ s- A' x! ]  i=i+1;
- D( M$ |) O+ K: V: n% j6 U) d: R: Zend
; o& W0 r: W4 l: B
4 m5 p' f4 u. a9 a! Y
$ q0 K/ G" Y) q
9 ~. ], b4 h$ K4 A& o
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data9 c7 t* J1 @. V" y. d0 y: y6 f

' _3 x, f) W! }& r8 u2 }nlines=length(concentrations);cmap=hsv(nlines)( }; ?( U4 R2 O1 U" v2 i
c=concentrations-min(concentrations);
, C! P" O: [1 S' b. kc=ceil(c/max(c)*nlines);
1 N) X( {) i! m( f( J) n% M7 L# X' p% sfor ii=1:nlines
5 v0 ^: k+ i2 v$ E. }, H5 B6 l( f( Z plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))  ~2 }7 G2 s0 Z% P% ?: }
hold on;
/ o5 G$ L1 S$ S2 |( Iend' W2 f" O* h' c8 x5 @5 J
hold off;+ E9 N7 B1 j  e

4 x6 [- D0 }% g2 |7 f
' N0 I! \& E8 I+ G# M# b  H
0 U3 N" m8 D0 v; t$ f9 _

& T. p% ^0 J. p. A, K6 H                    / Q' h# P+ ^) X4 M! ?. H5 M; H+ p
( A2 r2 r0 B# a# ~* r  E- n
                                        转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。
回复

举报 使用道具

相关帖子

全部回帖
暂无回帖,快来参与回复吧
懒得打字?点击右侧快捷回复 【吾爱海洋论坛发文有奖】
您需要登录后才可以回帖 登录 | 立即注册
黄金品质
活跃在2021-12-8
快速回复 返回顶部 返回列表