垂直errorbar很容易实现,水平errorbar也经常用到,但网上很多方法都很复杂,在这里介绍一种相对简单的方法:+ g% M1 Z( p3 B. B
) h- C) J5 l# ^* g. M" P实例:! y2 d8 W; T7 N- N: m. w
方法1:& y6 M! V0 B0 V5 q4 n3 Y/ ^2 y
figure;
* t2 k5 s" D0 N5 q6 U- V( H" L, [ err=data_std*ones(size(depth,2)); 3 a1 |: z: z/ d ?7 L' _1 y3 S
errorbar(depth,data_av,err,'-r','linewidth',2) %先画垂直方向的errorbar0 e; [! k' p( ^& h9 m+ R8 w- G, @
hold on; p5 S7 I2 n, @! V+ E
plot(depth,data_av,'k-','linewidth',2)# \4 Y# d5 v' y
view(-90,90) %变换图像视角" h9 `9 a% e9 Y$ R: U
set(gca,'xdir','reverse','ydir','reverse','linewidth',2,'fontsize',15) %调转坐标轴
1 E8 H8 r7 `( M) O8 d/ g xlim([0 max(depth)+100])
1 b. o# c1 E: R9 x. I: v grid on;
r# M! O- R6 F" y8 m, s; @ 上述方法仅适用于matlab2014a之前的版本,在2017a版本不适用;
" C1 n u \* {% c- ~0 Y5 _7 ~1 C( h! l/ R
5 e" ]- c$ z1 H/ d$ e. x
方法2:5 B. o) Z8 y+ M# ]
利用子程序herrorbar
4 j2 R& z1 p8 D8 o* t/ A 7 ?9 @6 [) K( O0 Z/ Y
www.52ocean.cn
% D" Z6 ]3 J) B0 c. Q. U1 v调用方法:
{: K* e* D8 pclose all;figure + Q5 M/ M9 S7 v" a
hold on;
: L: k, i- l0 y; i) }, N6 l' t9 d2 { plot(U_mean,depth,'r-o','linewidth',2) 1 O4 d' M& Z) o) `* _1 o
err_U=U_std; # P8 `% b- q! N$ k0 V7 g
h=herrorbar(U_mean,depth,err_U,'r-');
$ e. M6 R# U5 W9 J& G9 L0 o2 W set(h,'linewidth',2) 3 U0 a' n7 U4 R8 t0 T
. X7 p: z- ?; w! r' U
% E* x8 E! f1 P% O 9 b; r* _& S, F
" P$ a* @. D" Z3 I 转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |