【MATLAB】如何画水平errorbar

[复制链接]
垂直errorbar很容易实现,水平errorbar也经常用到,但网上很多方法都很复杂,在这里介绍一种相对简单的方法:
9 r) C# w2 ]* ?0 X) `9 M( x& H$ x; u5 J
7 W( [9 D/ T! O实例:
: l8 \1 ^: N: r7 X* y7 S! i# ~方法1:
: a: c- l, I: D6 e6 p: Ufigure;' n* b) d' b- y( B
    err=data_std*ones(size(depth,2));                       ; k$ r- Y: P3 z( b! ^! k1 Y6 c
    errorbar(depth,data_av,err,'-r','linewidth',2) %先画垂直方向的errorbar* `+ x) |: [# C% k9 ?, ~& K* Y: f
    hold on;
4 R% Q+ L, K# s  b  _    plot(depth,data_av,'k-','linewidth',2)
$ }' Z# q9 t1 X8 r. O/ f5 H6 K9 R' p    view(-90,90)    %变换图像视角
. L4 U$ C/ h' }( s! H, U8 \    set(gca,'xdir','reverse','ydir','reverse','linewidth',2,'fontsize',15)  %调转坐标轴- ~& `4 [& x' {# Y5 {
    xlim([0 max(depth)+100])
* a- R' l; }2 V! I    grid on;
* p0 x5 @7 ~, E& g, C2 w    上述方法仅适用于matlab2014a之前的版本,在2017a版本不适用;
. H% X+ ]6 A0 r/ w  y0 ~4 r9 {  t" l, H* ^" |! m, h: n2 F

9 H/ K( Y9 U) w" g! R0 s方法2:, p  Y1 Q8 U3 M% g
利用子程序herrorbar, ]* L* \' f! v5 b* D! y. j# Y
- \* k+ H& P) K# R% t8 o. j8 r
                               
www.52ocean.cn" F# e) H2 N* M
调用方法:
/ n0 ?. w' C0 y: {1 T& |; tclose all;figure     % Y. L% I) b8 b+ x7 l* B+ v
        hold on;
  D; A+ `! ^  o$ X        plot(U_mean,depth,'r-o','linewidth',2)
( a% H0 l! @7 }2 o        err_U=U_std;. v3 R7 c: w! `5 `4 ^1 j; M
        h=herrorbar(U_mean,depth,err_U,'r-');
0 }! X/ F& S2 T8 n* X) v        set(h,'linewidth',2)2 u) ]4 H- B. l( \; Y

' m0 M: Q, m; i, ^; E/ w- j* a5 j4 c5 V( E4 P: c$ X9 i; _
                    
' i1 \4 s3 I9 ~
& V" i1 @2 I: o( ~                                        转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。

相关帖子

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