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

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

[复制链接]
1. 参考 www.52ocean.cn
2 w  [# t0 N# k4 Cdc=hsv(18);           % 18 colours are generated" g6 D; f7 o2 N) `& S
x = 0:pi/100:2*pi;
6 G2 o8 m. }* p  l( d0 T. xhold on                  % you much write this before the plot
9 k" H* b6 _, k, e8 [i=1;
8 ~& K0 o4 K: ^8 Xfor d=0:0.2:2,   % 11 lines in plot are taken4 F  W" m/ t5 H' U# W0 {
  plot(x,sin(x-d),'color',dc(i,,'linewidth',2)% b$ y- N$ Z# r8 A' i+ A
  i=i+1;
- ~6 K- s& [) n& L+ z4 u1 `end
, `8 i  m- U. H1 R' K5 T; i0 n6 F+ }5 h: y2 W* s4 p8 T

6 H  v/ u) |6 y+ D6 u8 J* U  L0 l
/ W8 i: {' s" ~) L1 Q# }
2.参考http://stackoverflow.com/questions/37111362/matlab-plot-and-color-samples-based-on-data
* ^/ s) T4 o4 M
$ ~4 n2 T6 o" p" m9 Unlines=length(concentrations);cmap=hsv(nlines)
/ D% W2 w) s' ?/ cc=concentrations-min(concentrations);, t  i+ u! f; s5 R2 }
c=ceil(c/max(c)*nlines);4 {2 B3 P* |# y
for ii=1:nlines- ~' z% K. |- W. X% l$ @7 h9 m0 B+ [
plot(wavelength,dataMatrix(ii,:),'Color',cmap(c(ii),:))
3 q( L5 ^3 K+ _- G2 _2 f6 | hold on;6 }4 B# R% D0 t$ ?  O
end
3 e! I: t' Q, X3 E7 l6 qhold off;" s$ u4 T9 e* \- X

/ Z8 s& K! d1 k( R! i6 O# p5 o9 W0 R* Z2 a2 z  H
, ?0 l  @3 O, {8 k
; e# Y& U; s3 l: {" n
                    # L- S, A4 r; h, _' w- D9 T

! f2 }+ \4 i$ E! |, p) f# R                                        转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。
回复

举报 使用道具

相关帖子

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