-
Notifications
You must be signed in to change notification settings - Fork 0
/
lineplot_multitraces.m
executable file
·199 lines (189 loc) · 5.91 KB
/
lineplot_multitraces.m
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
% author: Ainray
% email: wwzhang0421@163.com
% date: 20220211
% modified: 20220211, for plot rf waveform data, rf are arragend by columns
% 20220219, specify axes
% function lineplot_multitraces(x,z,scale,step,type,rcv,str,log,exc, clr, lw)
% lineplot_multitraces is used to dispaly multi trace data in the same temporal or spacical scale
% Input:
% x, the temporal or spacial sampling node, more closer to the top or
% the left, more early or more near
% z, the multi-channel data, every column is a time series of a
% receiver, more closer to the top, the more previous time from now
% scale, the scale vetor, supporting diffrent scaling for different trace
% step, the step between two traces, supporting varying step
% type, two common display ways:
% 1. like seismic section time series in the same spacial scale.
% 11. filled version
% 2. spacial series in the same temporal scale.
% 21. filled version
% log, whether using logarithmic scale
% exc, the exclued trace indices or temporal node indices
% rcv, the postion indices
function lineplot_multitraces(x,z,scale,step,type,rcv,str,log,exc, clr, lw, iscenter, ax)
if nargin<6|| isempty(rcv)
rcv=step;
end
if nargin<7|| isempty(str)
str = [];
end
if nargin<8|| isempty(log)
log=0;
end
if nargin<9 || isempty(exc)
exc=-1;
end
if nargin < 10 || isempty(clr)
clr= 'r';
end
if(nargin<11 || isempty(lw))
lw = 1;
end
if(nargin<12 || isempty(iscenter))
iscenter = 0;
end
if(nargin <13 || isempty(ax))
ax = gca;
end
if length(x) == numel(x)
% x=v2col(x);
x = x(:);
end
[m,n]=size(z);
[mx,nx]=size(x);
if(type==1) % vertial view from top to bottom
hold(ax,'on');
for i=1:n
if(isempty(find(i==exc, 1))) %excluded ones
if length(x) ~= numel(x)
xx=x(:,i);
else
xx=x;
end
if(log==1) % plot the ith trace of data
semilogy(z(:,i)*scale(i)+sum(step(1:i)),xx,'k');
else
plot(z(:,i)*scale(i)+step(i)*i,xx,'k')
end
% hold on;
end
if(log==1) % plot center line
semilogy([sum(step(1:i)),sum(step(1:i))],[xx(1),xx(end)],'--k');
else
plot([sum(step(1:i)),sum(step(1:i))],[xx(1),xx(end)],'--k');
end
end
axis([0,sum(step),min(min(x))-0.1*min(min(x)),max(max(x))]);
axis ij; % flip up-down the fiugre
elseif type==11 % filled version of type 1, not support log-scale
hold(ax,'on');
for i=1:n % plot the ith trace of data
if(isempty(find(i==exc, 1)))
ss=sum(step(1:i));
if length(x) ~= numel(x)
xx=x(:,i);
else
xx=x;
end
fill([z(:,i)*scale(i)+ss;ss*ones(m,1)],[xx;xx(end:-1:1)],'r','edgealpha',0);
end
% hold on;
% center line
plot([sum(step(1:i)),sum(step(1:i))],[xx(1),xx(end)],'-r');
end
axis([0,sum(step)+step(end),min(min(x))-0.1*min(min(x)),max(max(x))]);
axis ij;
% xlabel('Distance (m)','Fontsize',14);ylabel('Time (s)','fontsize',14);
% if ~isempty(str)
% title(str,'fontsize',14);
% end
% set(gca,'yTicklabel',get(gca,'yTicklabel'),'Fontweight','bold','Fontsize',14,...
% 'xTicklabel',v2col(rcv));
% xt=get(gca,'xTick');
% if(xt(1)<step(1))
% xt(1)=step(1);
% end
% if(xt(end)>sum(step))
% xt(end)=sum(step);
% end
% if xt(end)<sum(step)
% xt=[xt,sum(step)];
% end
% [~,loc]=ismember(xt,cumsum(step));
% set(gca,'xTick',xt,'xTickLabel',rcv(loc));
% if log==1
% set(gca,'yscale','log');
% end
elseif type==2 % horizontal version
hold(ax,'on');
if iscenter == 1
for i=1:n % i the time step
if(isempty(find(i==exc, 1)))
if length(x) ~= numel(x)
xx=x(:,i);
else
xx=x;
end
plot(ax, [xx(1),xx(end)],[sum(step(1:i)),sum(step(1:i))],['-',clr]);
end
end
end
for i=1:n % i the time step
if(isempty(find(i==exc, 1)))
if length(x) ~= numel(x)
xx=x(:,i);
else
xx=x;
end
if(log==1)
semilogx(ax,xx,z(:,i)*scale(i)+step(i)*i,clr, 'linewidth',lw);
else
plot(ax, xx,z(:,i)*scale(i)+sum(step(1:i)),clr, 'linewidth',lw);
end
end
end
axis(ax, [min(min(x))-0.1*min(min(x)),max(max(x)),0,sum(step)+step(end)]);
% ytickindex = 1:3:length(step);
% nytick = length(ytickindex);
% ytick_ = zeros(nytick,1);
% for i = 1:nytick
% ytick_(i)=sum(step(1:ytickindex(i)));
% end
% set(gca,'yTick',ytick_,'yTicklabel',rcv(1:3:end));
elseif type==21
hold(ax,'on');
if mx>1 && nx==1
x=x';
end
for i=1:n % i the time step
if(isempty(find(i==exc, 1)))
if(log==1)
semilogx(x,z(:,i)*scale(i)+step(i)*i,'r');
else
plot(x,z(:,i)*scale(i)+sum(step(1:i)),'r');
end
% hold on;
% x=v2col(x);
x=x(:);
X=[x',fliplr(x')];
y2=z(:,i)*scale(i)+sum(step(1:i));y2=y2';
y1=ones(1,length(x))*sum(step(1:i));
Y=[y1,fliplr(y2)];
fill(X,Y,'r');
end
end
for i=1:n
plot([x(1),x(end)],[sum(step(1:i)),sum(step(1:i))],'-k');
end
cc=0;
for i=1:3:length(step)
cc=cc+1;
ytick_(cc)=sum(step(1:i));
end
set(gca,'yTick',ytick_,'yTicklabel',rcv(1:3:end));
% yticklabel_rotate(ytick_,90);
axis([min(x)-0.1*min(x),max(x),0,sum(step)+step(end)]);
else
error(1,'type must be either 1,2 or 3,4');
end
hold(ax,'off');