MATLAB Answers

## Subplot without stretching images?

Asked by Isktaine

### Isktaine (view profile)

on 19 Sep 2012
Hi,
I have three figures and want to combine them in a long rectangular image so they can be viewed side by side. I've used subplot but this 'squashes' the figures so they are not very readable. Is there a function that allows three figures to effectively be concatenated into one larger image?
Thanks,
isktaine

#### 0 Comments

Sign in to comment.

## 1 Answer

### José-Luis (view profile)

Answer by José-Luis

### José-Luis (view profile)

on 19 Sep 2012
Edited by José-Luis

### José-Luis (view profile)

on 19 Sep 2012

You can create custom axes, e.g.:
ax(1) = axes('Position',[0.05 0.1 0.3 0.8]);
ax(2) = axes('Position',[0.35 0.1 0.3 0.8]);
ax(3) = axes('Position',[0.65 0.1 0.3 0.8]);
And manipulate their properties so they look how you want
Or for an arbitrary number of axes:
n = 4; % How many you need?
ax = ones(1,n); %Handle so you can plot afterward
width = 0.9 / n;
for ii = 0:n-1
ax(ii+1) = axes('Position',[(0.05+(width*ii)) 0.1 width 0.8]);
end

#### 4 Comments

Show 1 older comment
José-Luis

### José-Luis (view profile)

on 19 Sep 2012
n = 4;
ax = ones(1,n);
gap = 0.05;
totGap = gap * (n-1);
width = (0.9-totGap) / n;
effWidth = width + gap;
for ii = 0:n-1
ax(ii+1) = axes('Position',[(0.05+(effWidth*ii)) 0.1 width 0.8]);
end
Isktaine

### Isktaine (view profile)

on 19 Sep 2012
Sorry but if I use this I still get it plotting in a square figure, so it doesn't really fix my problem.
José-Luis

### José-Luis (view profile)

on 19 Sep 2012
I don't understand what you mean. If your image is distorted, maybe:
axis equal
would work.

Sign in to comment.