Make figures with different y limits but same distance between yticks

I would like to make two figures where the y ticks when printed have the same size, but with different y limits. So if I e.g. do the following
fig1=figure;
ylim([0 10])
%plot some stuff
xlabel('xlabeltext')
print('-dpdf','fig1.pdf')
fig2=figure;
ylim([0 18])
ax2=gca;
ax2.XTickLabel=[];
print('-dpf','fig2.pdf')
I would want the ticks on the y axis of fig1 to be 0:10, with a distance of, say, 1 cm between them when printed, and the ticks on the y axis of fig2 would be 0:18 also with a distance of 1 cm between them when printed.
Naively I would change the 'position' property:
fig1=figure('position',[680 558 560 420]);
ylim([0 10])
%plot some stuff
xlabel('xlabeltext')
print('-dpdf','fig1.pdf')
fig2=figure('position',[680 558 560 420*18/10]);
%plot some stuff
ax2=gca;
ax2.XTickLabel=[];
ylim([0 18])
print('-dpf','fig2.pdf')
However, this doesn't quite work, presumably because the axes, xlabel x tick labels take up some of the figure.

Answers (0)

Tags

Asked:

on 14 Jan 2019

Community Treasure Hunt

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

Start Hunting!