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

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

[复制链接]
1. 参考 www.52ocean.cn$ I- i5 l: I% `' ?5 w4 M
dc=hsv(18);           % 18 colours are generated  B7 s& Q* X! t" x  o1 h
x = 0:pi/100:2*pi;
+ k- V2 L; q9 Y' w9 T8 f7 Dhold on                  % you much write this before the plot
$ l5 D/ n. a* X/ S3 K2 @i=1;
5 c+ ?) I) R4 q: X. a& Ufor d=0:0.2:2,   % 11 lines in plot are taken+ F- {# k1 S% F% ^' c% ~# v
  plot(x,sin(x-d),'color',dc(i,,'linewidth',2)
; L: @9 ~9 g( y  i=i+1;( m. A  r" H" B+ _. C8 T' C- `
end
( A6 n& U: N, k: e4 L" O
( D7 U( W) n  i& b
2 w& E4 X9 j8 z( M

" b: U2 k8 V1 A7 \& _# \/ m5 J$ q2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data) l7 S" }3 m7 U$ R+ O

% g8 y3 w7 t, v, e5 }) A+ {. Nnlines=length(concentrations);cmap=hsv(nlines)
5 b( S- f. m" @7 qc=concentrations-min(concentrations);5 |4 ^" B7 r, v1 ]) a& a7 R$ }- J
c=ceil(c/max(c)*nlines);
' m1 ~! C5 N2 {4 Dfor ii=1:nlines
# x6 W+ x7 _# y7 x9 e plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))4 G- i' }$ G) M
hold on;9 j, V" ?3 A6 y; t  [! O
end& S1 A& f3 z# l' K: H3 g6 ^5 |
hold off;
8 I/ @, W- u+ L# }; X7 E
- V! J3 B  F2 F! j( e. ]
) Z4 \- Z; O1 u
. Y3 w) B- C+ ?0 [  \# f
+ d* n, A# S8 \) d) V. ^$ n
                      A; W1 D" R. u! c1 t! [

0 g% E3 w: Q+ k0 b! x/ @# m" W                                        转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。
回复

举报 使用道具

相关帖子

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