0
|
1 |
function hh = xerrorbar(x, y, l,u,symbol)
|
|
2 |
%XERRORBAR Error bar plot.
|
|
3 |
%
|
|
4 |
% XERRORBAR(X,Y,L,U) behaves similar to ERRORBAR, from which it was
|
|
5 |
% derived
|
|
6 |
%
|
|
7 |
% Global Variables:
|
|
8 |
% TICSLEN half-length of ticmarks in terms of y units;
|
|
9 |
% +ve values: y units;
|
|
10 |
% -ve values: fraction of y total y-range;
|
|
11 |
% default: -0.005
|
|
12 |
% ERRORBARS_ONLY do not plot data points
|
|
13 |
|
|
14 |
%======================================================================
|
|
15 |
% X E R R O R B A R . M
|
|
16 |
% doc: Sun Feb 23 08:55:37 2003
|
|
17 |
% dlm: Tue Mar 11 11:52:52 2003
|
|
18 |
% (c) 2003 Mathworks; changes by A.M. Thurnherr
|
|
19 |
% uE-Info: 137 49 NIL 0 0 72 2 2 8 NIL ofnI
|
|
20 |
%======================================================================
|
|
21 |
|
|
22 |
% HISTORY:
|
|
23 |
% Feb 23, 2003: - created from [errorbar.m]
|
|
24 |
% Mar 10, 2003: - added TICSLEN
|
|
25 |
% Mar 11, 2003: - changed TICSLEN sign convention
|
|
26 |
% - added ERRORBARS_ONLY
|
|
27 |
|
|
28 |
global TICSLEN; if isempty(TICSLEN), TICSLEN = -0.005; end
|
|
29 |
global ERRORBARS_ONLY;
|
|
30 |
|
|
31 |
if min(size(y))==1,
|
|
32 |
npt = length(y);
|
|
33 |
x = x(:);
|
|
34 |
y = y(:);
|
|
35 |
if nargin > 2,
|
|
36 |
if ~isstr(l),
|
|
37 |
l = l(:);
|
|
38 |
end
|
|
39 |
if nargin > 3
|
|
40 |
if ~isstr(u)
|
|
41 |
u = u(:);
|
|
42 |
end
|
|
43 |
end
|
|
44 |
end
|
|
45 |
else
|
|
46 |
[npt,n] = size(y);
|
|
47 |
end
|
|
48 |
|
|
49 |
if nargin == 3
|
|
50 |
if ~isstr(l)
|
|
51 |
u = l;
|
|
52 |
symbol = '-';
|
|
53 |
else
|
|
54 |
symbol = l;
|
|
55 |
l = x;
|
|
56 |
u = x;
|
|
57 |
x = y;
|
|
58 |
[m,n] = size(x);
|
|
59 |
y(:) = (1:npt)'*ones(1,n);;
|
|
60 |
end
|
|
61 |
end
|
|
62 |
|
|
63 |
if nargin == 4
|
|
64 |
if isstr(u),
|
|
65 |
symbol = u;
|
|
66 |
u = l;
|
|
67 |
else
|
|
68 |
symbol = '-';
|
|
69 |
end
|
|
70 |
end
|
|
71 |
|
|
72 |
|
|
73 |
if nargin == 2
|
|
74 |
l = x;
|
|
75 |
u = x;
|
|
76 |
x = y;
|
|
77 |
[m,n] = size(x);
|
|
78 |
y(:) = (1:npt)'*ones(1,n);;
|
|
79 |
symbol = '-';
|
|
80 |
end
|
|
81 |
|
|
82 |
u = abs(u);
|
|
83 |
l = abs(l);
|
|
84 |
|
|
85 |
if isstr(x) | isstr(y) | isstr(u) | isstr(l)
|
|
86 |
error('Arguments must be numeric.')
|
|
87 |
end
|
|
88 |
|
|
89 |
if ~isequal(size(x),size(y)) | ~isequal(size(x),size(l)) | ~isequal(size(x),size(u)),
|
|
90 |
error('The sizes of X, Y, L and U must be the same.');
|
|
91 |
end
|
|
92 |
|
|
93 |
if TICSLEN < 0
|
|
94 |
tee = (max(y(:))-min(y(:))).*-TICSLEN;
|
|
95 |
else
|
|
96 |
tee = TICSLEN;
|
|
97 |
end
|
|
98 |
yl = y - tee;
|
|
99 |
yr = y + tee;
|
|
100 |
xtop = x + u;
|
|
101 |
xbot = x - l;
|
|
102 |
n = size(x,2);
|
|
103 |
|
|
104 |
% Plot graph and bars
|
|
105 |
hold_state = ishold;
|
|
106 |
cax = newplot;
|
|
107 |
next = lower(get(cax,'NextPlot'));
|
|
108 |
|
|
109 |
% build up nan-separated vector for bars
|
|
110 |
yb = zeros(npt*9,n);
|
|
111 |
yb(1:9:end,:) = y;
|
|
112 |
yb(2:9:end,:) = y;
|
|
113 |
yb(3:9:end,:) = NaN;
|
|
114 |
yb(4:9:end,:) = yl;
|
|
115 |
yb(5:9:end,:) = yr;
|
|
116 |
yb(6:9:end,:) = NaN;
|
|
117 |
yb(7:9:end,:) = yl;
|
|
118 |
yb(8:9:end,:) = yr;
|
|
119 |
yb(9:9:end,:) = NaN;
|
|
120 |
|
|
121 |
xb = zeros(npt*9,n);
|
|
122 |
xb(1:9:end,:) = xtop;
|
|
123 |
xb(2:9:end,:) = xbot;
|
|
124 |
xb(3:9:end,:) = NaN;
|
|
125 |
xb(4:9:end,:) = xtop;
|
|
126 |
xb(5:9:end,:) = xtop;
|
|
127 |
xb(6:9:end,:) = NaN;
|
|
128 |
xb(7:9:end,:) = xbot;
|
|
129 |
xb(8:9:end,:) = xbot;
|
|
130 |
xb(9:9:end,:) = NaN;
|
|
131 |
|
|
132 |
[ls,col,mark,msg] = colstyle(symbol); if ~isempty(msg), error(msg); end
|
|
133 |
symbol = [ls mark col]; % Use marker only on data part
|
|
134 |
esymbol = ['-' col]; % Make sure bars are solid
|
|
135 |
|
|
136 |
h = plot(xb,yb,esymbol); hold on
|
|
137 |
if ~ERRORBARS_ONLY, h = [h;plot(x,y,symbol)]; end
|
|
138 |
|
|
139 |
if ~hold_state, hold off; end
|
|
140 |
|
|
141 |
if nargout>0, hh = h; end
|