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

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

[复制链接]
1. 参考 www.52ocean.cn
0 O9 }9 L- ~& g2 w! bdc=hsv(18);           % 18 colours are generated
. d% q& |$ `( I; G  Ix = 0:pi/100:2*pi;
" @% i. W( |1 C7 Qhold on                  % you much write this before the plot2 R0 s9 \/ |: D: y) x  @
i=1;+ y; X, u2 L* ]' m2 c
for d=0:0.2:2,   % 11 lines in plot are taken
  n% y) Z8 s) ^  plot(x,sin(x-d),'color',dc(i,,'linewidth',2)( G! T+ Z% ~& \! D
  i=i+1;
4 D- c" i  I2 W( q; kend9 s0 F2 ]4 p% I8 w; K

# w0 f# ?% E+ n, [1 J. P! R; I
6 z8 l$ `, L% @) N
3 d8 {. n4 D4 W! b# P
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
4 K% m: P7 Y1 `, b6 s
0 W: N8 S8 a2 K; b) gnlines=length(concentrations);cmap=hsv(nlines)1 {3 V: I; d' [4 r3 }
c=concentrations-min(concentrations);( g7 y) o4 {3 U8 e4 y* O
c=ceil(c/max(c)*nlines);  a8 u; X) K2 `1 d
for ii=1:nlines2 D8 ?  K, n5 [0 ]+ ]
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:)): o5 @. |4 `$ i! |, R
hold on;- k6 H& k+ q8 G- R  ?9 |  B  B
end
  i/ Q" a, F* c- L" a9 B5 e+ Chold off;
) |6 O+ Y7 x; {/ h  r
* O; c, n) J) H# i/ W# ?% @; |% {& @8 c' H' O5 S6 Z

- C/ r4 A& I, A6 _
3 I( \+ v6 n9 ]' C: C                    
# o# `/ h4 G0 \5 w5 V8 e, X6 W+ v
8 i- R$ a. [; ]; y' N- s; Q                                        转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。
回复

举报 使用道具

相关帖子

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