# Vertically align bottom edge of subplots

6 views (last 30 days)
Jason Duvall on 15 Nov 2019
The following code
fig = figure;
alist = [-0.1 1 4];
cp = 0;
for counter = 1:3
a = alist(counter);
fp = [(1+sqrt(1+4*a))/(-2*a) (1-sqrt(1+4*a))/(-2*a)];
fpmin = (abs(fp(1)-cp) < abs(fp(2)-cp))*fp(1) + (abs(fp(1)-cp) >= abs(fp(2)-cp))*fp(2);
fpmax = (abs(fp(1)-cp) >= abs(fp(2)-cp))*fp(1) + (abs(fp(1)-cp) < abs(fp(2)-cp))*fp(2);
ax = axes('Position',[.1+(counter-1)*0.3 0 0.25 1]);
axis equal;
hold on;
fplot(@(x) 1-a*x.^2,'color','k');
fplot(@(x) x,'--','color','b');
plot([fpmax -fpmax -fpmax fpmax fpmax],[fpmax fpmax -fpmax -fpmax fpmax],'color','r');
end
produces the following image: The issue is that MATLAB didn't place the third image correctly. The line of code
ax = axes('Position',[.1+(counter-1)*0.3 0 0.25 1]);
supposedly tells MATLAB to position the bottom left corner of each new axis at a height of 0. But this isn't happening in the third image. I also tried using subplots but that produces the same behavior as seen above. How do I vertically align the three axes along their bottoms, if the 'Position' thing I tried doesn't work?

Abhisek Pradhan on 19 Nov 2019
I was able to reproduce the problem using your code.
ax = axes('Position',[.1+(counter-1)*0.3 0 0.25 1]);
the above line of code is working as expected. But