Why do my subplots not line up?

Why do my y-axes not line up for my subplots? Text file and importfileIRIasia.m attached.
clear all
close all
%%%%%%%%%%%%%%%%%%%
[filenames, pathname, filterindex] = uigetfile({'*.txt','txt-files (*.txt)'; ...
'*.*','All files'},'Select EISCAT files','MultiSelect', 'on');
importfileIRIasia(filenames)%'smoothasia.txt'
ne=smoothasia(:,2);%L(:,1);
Alt =smoothasia(:,1);%(0:10.01:1000);
idx=find(Alt==1000);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%HERE DOWN%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Allones=ones(1,100);
IRIpriori=(smoothasia(1:idx,2)*Allones);%IRIpriori=(x2*Allones);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lat = 0:0.182:18.1;%55:0.251:80;
figure,
subFig1=subplot(3,4,[2:4 6:8 10:12]);%subplot(1,2,1)
pcolor(lat, Alt(1:idx),IRIpriori(1:idx,:)), shading 'interp';
xlim([min(lat) max(lat)])%([55 80])
xlabel('Latitude(Degree)','fontsize',24, 'fontweight','bold')
ylabel('Altitude (km)','fontsize',24, 'fontweight','bold')
xlabel(colorbar,'m-3','fontsize',24, 'fontweight','bold')
set(gca,'FontSize',24)
subFig2=subplot(3,4,[1 5 9]);%subplot(1,2,2)
plot(IRIpriori(1:idx,1),Alt(1:idx)) %profile of the surface.
xlim([min(ne) max(ne)])
xlabel('m-3','fontsize',24, 'fontweight','bold')
ylabel('Altitude (km)','fontsize',24, 'fontweight','bold');
set(gca,'FontSize',24)
colormapeditor

6 Comments

what do you mean by line up?
KSSV
KSSV on 12 Dec 2018
Edited: KSSV on 12 Dec 2018
Try arranging/ setting the figure sizes. Or you can set yaxes invisible.
set(gca,'ytick',[])
Alex
Alex on 12 Dec 2018
Edited: Alex on 12 Dec 2018
The altitude of the peak in the left plot does not line up with the peak of the pcolor plot on the right. The y-axes labels and ticks also do not line up .
I don't know what you mean by arranging or setting the sizes.
set the first subplot ytick as
ytick([100:100:1000])
It is not only the tick marks that are not lining up. The plotted data does not line up. The peak of the plot on the left occurs at a higher altitude than the pcolor plots peak (dark red line).
I feel it is plotting fine:
Capture.PNG

Sign in to comment.

 Accepted Answer

KSSV
KSSV on 12 Dec 2018
Use axis tight after plot in second subplot.

1 Comment

Perfect, that solves the problem! Greatly appreciated!

Sign in to comment.

More Answers (0)

Tags

Asked:

on 12 Dec 2018

Commented:

on 12 Dec 2018

Community Treasure Hunt

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

Start Hunting!