how to make subplots with different heights?

20 views (last 30 days)
Mr M.
Mr M. on 14 Apr 2015
Answered: Image Analyst on 15 Apr 2015
I would like to plots below each other, but the first one is a picture with small height. I dont want large empty space. How to set the height of the first
subplot? Or automatically adjust it?
subplot(2,1,1)
imagesc(mypicture)
subplot(2,1,2)
plot(randn(100,1))

Answers (1)

Image Analyst
Image Analyst on 15 Apr 2015
Set the 'OuterPosition' property of the axes control that subplot creates
h1 = subplot(2,1,1);
set(h1, 'OuterPosition', [0,0.51, 1, .4]);
mypicture = imread('cameraman.tif');
imagesc(mypicture)
h2 = subplot(2,1,2);
set(h2, 'OuterPosition', [0,0, 1, .4]);
plot(randn(100,1))
Take great care with the position values because if the second axes overlaps the first one at all, none of the first one will show up.

Community Treasure Hunt

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

Start Hunting!