垂直errorbar很容易实现,水平errorbar也经常用到,但网上很多方法都很复杂,在这里介绍一种相对简单的方法:1 }: X ^, r9 @1 _$ {9 o3 f
* o1 g4 r7 U9 q" M" a1 S- B实例:
5 o- u, q+ x4 h6 P方法1:# r4 \4 Y9 s6 C: u/ Z U8 a
figure;& K, W8 j9 M2 ?% V7 A' r: ]9 @
err=data_std*ones(size(depth,2));
" ~. S( D$ t. e0 j0 r: f; l errorbar(depth,data_av,err,'-r','linewidth',2) %先画垂直方向的errorbar8 o- E9 u$ C6 @1 G
hold on;
N. E7 V& M$ @" p$ B, y plot(depth,data_av,'k-','linewidth',2)
' W C! {! a; x \+ H6 T* m view(-90,90) %变换图像视角
: a2 R3 e! A8 U' M4 C set(gca,'xdir','reverse','ydir','reverse','linewidth',2,'fontsize',15) %调转坐标轴
+ D e$ ]7 \, N4 m: j* T# ~ xlim([0 max(depth)+100])- {; |5 F; |& ]3 R( K) P
grid on;7 N5 l& {) Q: f
上述方法仅适用于matlab2014a之前的版本,在2017a版本不适用;
) M6 ?1 a' g$ \% v* m0 b
" P; D- c% o. N( x. [# S% v3 M7 S" F' v1 h$ ^& F V. X
方法2: w2 l! a7 ^" t5 f* J7 A1 q
利用子程序herrorbar% i# _* U0 a7 S- T
, U! @$ Z; Y" t; n1 d7 @ www.52ocean.cn( ^, X% \) a! |' N; u k
调用方法: / L3 x* X+ z& v5 z8 b, X
close all;figure
, s3 y/ r8 s, G( U W hold on;
, Q: |9 Y9 ?. Z0 k0 e plot(U_mean,depth,'r-o','linewidth',2) ) M) \, E I* w- q* p
err_U=U_std;
8 {; h3 u7 w0 ~1 _; i6 ?. L h=herrorbar(U_mean,depth,err_U,'r-');
# z) u7 Z! d% P* x. b& I, n6 J6 q set(h,'linewidth',2) . j! C/ K* Y' ~' I- _2 M
3 w& g% x8 u5 q P' `
- L3 i" G: L6 _8 g3 @4 y
( X: A5 n0 d* |- k- J& i. c3 i5 y. c. ?
转载本文请联系原作者获取授权,同时请注明本文来自叶瑞杰科学网博客。 |