-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfun_mm_bar_baseline.m
More file actions
77 lines (62 loc) · 1.26 KB
/
fun_mm_bar_baseline.m
File metadata and controls
77 lines (62 loc) · 1.26 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function [h]=fun_mm_bar_baseline(x,y,baselinevalue,width,y_max,col_mm);
% [h]=fun_mm_bar_baseline(x,y,baselinevalue,width,y_max,col_mm)
% Inputs
% x : x
% y : y
% baselinevalue : the bottom line value
% width : the wdith of the bar
% y_max : the y max of the plot
% col_mm : the color, with this color, the bar is colored by hist value
%
% example :
%
% y = randn(1000,1);
% hi_va = hist(y,20);
% hi_va = hi_va./sum(hi_va);
% x = [11:30];
% blv = -0.02;
% wid = 0.8;
% ymax=0.5;% 4 plot
% col_mm = jet(100);
% [hbar_va1]=fun_mm_bar_baseline(x,hi_va,blv,wid,ymax,col_mm);
%%
blv = baselinevalue;
n = length(x);
[rx,cx]=size(x);
if rx==1;
x=x';
end
[ry,cy]=size(y);
if ry==1;
y=y';
end
n_col = length(col_mm(:,1));
X1 = x-0.5*width;
X2 = x+0.5*width;
Y1 = blv *ones(size(x));
Y2 = y;
% Y2
% size(X1)
% size(X2)
% size(Y1)
% size(Y2)
XL = [X1 X2 X2 X1 X1];
YL = [Y1 Y1 Y2 Y2 Y1];
hold on
for i = 1:n
% for i = 1:1
xlin = XL(i,:);
ylin = YL(i,:);
% size(xlin)
% size(ylin)
ind_col = floor((n_col-1)*y(i)/y_max)+1;
patch(xlin,ylin,col_mm(ind_col,:));
% patch(xlin,ylin,'r')
end
% hold on
% for i = 1:n
% xlin = [X1(i) X2(i) X2(i) X1(i) X1(i)];
% ylin = [Y1(i) Y1(i) Y2(i) Y2(i) Y1(i)];
% patch(xlin,ylin,col)
% end
h=gcf;