forked from hsinhungli/wmPriority_shared
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_errorbar.m
More file actions
58 lines (54 loc) · 1.22 KB
/
plot_errorbar.m
File metadata and controls
58 lines (54 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function [h1,h2]=myerrorbar(x,y,std,drawline,linecolor,wid,markersize,flip)
if isvector(x) && ~isrow(x)
x = x';
elseif ~isrow(x)
error('x has to be a row')
end
if isvector(y) && ~isrow(y)
y = y';
elseif ~isrow(y)
error('y has to be a row')
end
if isvector(std) && ~isrow(std)
std = std';
elseif ~isrow(std)
error('std has to be a row')
end
if length(x) ~= length(y)
error('x and y must be same length')
end
if ~exist('markersize','var') || isempty(markersize)
markersize = 5;
end
if ~exist('wid','var') || isempty(wid)
wid = 2;
end
if ~exist('drawline','var') || isempty(drawline)
drawline = 1;
end
if ~exist('linecolor','var') || isempty(linecolor)
linecolor = 'b';
end
if ~exist('flip','var') || isempty(flip)
flip=0;
end
if flip==0
h1 = plot([x;x],[(y-std);(y+std)]); hold on;
else
h1 = plot([x-std;x+std],[(y);(y)]); hold on;
end
if drawline==1
h2 = plot(x,y,'-o','MarkerSize',markersize);
elseif drawline==0
h2 = plot(x,y,'o','MarkerSize',markersize);
end
if exist('linecolor','var')
set(h1,'Color',linecolor)
set(h2,'Color',linecolor,'MarkerFaceColor',linecolor)
end
if exist('wid','var')
set(h1,'LineWidth',wid)
set(h2,'LineWidth',wid)
end
h1 = h1(1);
h2 = h2(1);