收藏本站 劰载中...网站公告 | 吾爱海洋论坛交流QQ群:835383472

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

[复制链接]
1. 参考 www.52ocean.cn
5 o6 E6 u8 b* }* B  U1 z" Jdc=hsv(18);           % 18 colours are generated9 U/ ~6 ^  ~, x9 l8 u) j* b7 w
x = 0:pi/100:2*pi;! i- [5 K/ x) @
hold on                  % you much write this before the plot
  D# ~1 W2 ~- E4 u# P% F0 y) \- {i=1;/ M* d- M* @% j; M
for d=0:0.2:2,   % 11 lines in plot are taken
1 ]' }2 e" p! W2 o5 @  plot(x,sin(x-d),'color',dc(i,,'linewidth',2)& k. r+ h0 X  p+ F1 r9 @  H+ |
  i=i+1;
, ~/ u8 U+ P* }end
* E$ T7 u5 o! i5 o+ |% [4 j( f( c
; d, C+ G; P* P  t: ?

: ^5 u2 x3 q& o2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
2 X7 j) d7 t9 C1 A  `3 u9 ]/ r/ A, ^5 E8 N
nlines=length(concentrations);cmap=hsv(nlines)
  A' W5 d2 t  [c=concentrations-min(concentrations);
* f( u! c' S8 K' Fc=ceil(c/max(c)*nlines);
, ]! W: ?( [  ]& E+ z. G$ ffor ii=1:nlines
+ A1 `$ z+ p& l" j- x3 h plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
- V$ L$ A# z# Z, f9 J: E3 t hold on;
. G1 y# }1 V3 Q: U; M9 }* V- dend
, O, r: N4 w: A9 Y7 Ihold off;
! d0 D4 K$ p" K4 L7 ^6 t* p/ V: i
. j3 A- B: h7 i; d8 I4 `0 [4 m! ?& F0 t
8 E# @% N! I: C! U* c7 c; U

. n; g4 f8 X. S: Q) N3 }. A# g6 Z
$ |! h* [6 A. O                    
2 D5 G# ~; S1 k5 U0 ^/ Z1 q; F+ N. M# z+ j1 Q5 L
                                        转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。
回复

举报 使用道具

相关帖子

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