plot traveltimes axes configuration

조회 수: 9 (최근 30일)
Ancalagon8
Ancalagon8 2018년 11월 11일
댓글: jonas 2018년 11월 12일
Hello, i have some seismic survey data (7 channels) and tried to plot them all in one figure without axes. So far so good but I want all 7 subplots to have one common x-axis and one common y axis. Any ideas?
My code is the following
clear all
load('G1.txt')
load('G2.txt')
load('G3.txt')
load('G4.txt')
load('G5.txt')
load('G6.txt')
load('G7.txt')
L=length(G1);
Fs=2048;
t=(L/1000) - 0.0001;
tvect = (0:0.001:t)';
figure
subplot (1,7,1)
plot (G1,tvect,'k')
hold on
ylim ([0 2])
haxes = gca;
axis off
set(gca,'Ydir','reverse')
subplot (1,7,2)
plot (G2,tvect,'k')
hold on
ylim ([0 2])
haxes = gca;
axis off
set(gca,'Ydir','reverse')
subplot (1,7,3)
plot (G3,tvect,'k')
hold on
ylim ([0 2])
haxes = gca;
axis off
set(gca,'Ydir','reverse')
subplot (1,7,4)
plot (G4,tvect,'k')
hold on
ylim ([0 2])
haxes = gca;
axis off
set(gca,'Ydir','reverse')
subplot (1,7,5)
plot (G5,tvect,'k')
hold on
ylim ([0 2])
haxes = gca;
axis off
set(gca,'Ydir','reverse')
subplot (1,7,6)
plot (G6,tvect,'k')
hold on
ylim ([0 2])
haxes = gca;
axis off
set(gca,'Ydir','reverse')
subplot (1,7,7)
plot (G7,tvect,'k')
hold on
ylim ([0 2])
haxes = gca;
axis off
set(gca,'Ydir','reverse')
  댓글 수: 2
jonas
jonas 2018년 11월 11일
편집: jonas 2018년 11월 11일
I'd give you some guidance but I don't understand what you mean.
"Hello, i have some seismic survey data (7 channels) and tried to plot them all in one figure without axes (as seen in picture1)."
without axes? There are seven axes in picture 1.
"So far so good but I want all 7 subplots to have one common x-axis and one common y axis (as seen in picture 2). Any ideas?"
What do you mean common axes? Do you want them plotted in the same axes or different axes that happen to share the same ylimits? I don't see how the plots in the second picture share x-axes. They are clearly plotted on separate x-axes and then you've added some line with labels on top.
If I had to guess, you want 7 axes with 6 hidden y-axis so that it appears as if they're plotted on a single axes. Then you want 7 different x-axes with the same limits, and perhaps you want to hide those xaxis. Finally, you want labels on each curve. Correct?
Ancalagon8
Ancalagon8 2018년 11월 12일
Exactly!

댓글을 달려면 로그인하십시오.

채택된 답변

jonas
jonas 2018년 11월 12일
편집: jonas 2018년 11월 12일
Try this. You can set 'xtick' to [], if you want to retain only the labels.
out = load('tvect.mat');
tvect = out.tvect;
for i=1:7
out = load(sprintf('G%g.mat',i));
data.(sprintf('G%g',i)) = out.(sprintf('G%g',i));
end
figure;hold on
for i=1:7
ax(i) = subplot(1,7,i,'ycolor','none','color','none',...
'xaxislocation','top');hold on
plot(data.(sprintf('G%g',i)),tvect);
xl(i) = xlabel(sprintf('G%g',i));
set(xl(i),'position',xl(i).Position)
text(0,0,sprintf('G%g',i),'horizontalalignment','center')
end
set(ax(1),'ycolor','k')
linkaxes(ax,'xy')
ylim([0 2])
  댓글 수: 5
Ancalagon8
Ancalagon8 2018년 11월 12일
Jonas thank you very much for your time and your help! That was exactly what i wanted!
jonas
jonas 2018년 11월 12일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by