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

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

[复制链接]
1. 参考 www.52ocean.cn
2 r. Z& q, b2 ?) y% Ydc=hsv(18);           % 18 colours are generated0 Q: B" L3 S" V/ w$ r# x$ G
x = 0:pi/100:2*pi;7 ~" s3 e+ S3 g0 P' w
hold on                  % you much write this before the plot
3 Q- D9 q* |! o/ j# m  e' Ki=1;5 D2 j2 a+ K) b
for d=0:0.2:2,   % 11 lines in plot are taken
: j$ z5 g1 }: s  o0 W$ z* U: T4 a/ u  plot(x,sin(x-d),'color',dc(i,,'linewidth',2); g# V  t7 Z$ g* t9 j8 f/ M
  i=i+1;* l3 j3 d0 o; S8 G& a
end' a+ F/ j$ g$ G& C. ^# |6 B) W' C- g
6 e. [, b; P% u

3 f# C$ p' A9 @  E2 |9 B

* T& d4 N- c- r& {8 H% t; Z0 z2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
. m4 Z0 n( p( h& ~+ L+ p1 v0 d3 X
0 `& e$ W* ?  v9 mnlines=length(concentrations);cmap=hsv(nlines)
, h6 R8 t8 \6 E& \4 g/ ic=concentrations-min(concentrations);
& |8 r0 ]8 j- g% ~$ Lc=ceil(c/max(c)*nlines);
' F( V. ?! B5 _3 }: U, b7 ]for ii=1:nlines/ B+ o" B# }! j) t( ]2 s$ ?, z) F
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
+ b! _" @$ }: Q4 a! ^ hold on;
/ N. y1 X( ^2 F* ]. _  g# b' C$ tend
$ i5 o! i' ?$ H; m) p' Uhold off;
( P8 t% Z# }% U; b* M( B" R- v
, U- i1 b/ L: U" @0 x' ]8 n& I3 Q5 u) E3 f& M& r$ X4 Y7 `8 c
: ?( p8 ?" p4 w7 ~' C4 x/ l( R  M
& O& i4 Y# C+ M* {9 U: N
                    
9 u/ c$ U5 `. ~$ |! U0 O: w, L1 ]
                                        转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。
回复

举报 使用道具

相关帖子

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