# How can I set the exact position of subplots in a figure?

871 views (last 30 days)
Michael Steinbuechler on 14 May 2018
Commented: Ameer Hamza on 14 May 2018
Hello Matlab-Pros,
I want to create subplots in a specific position on a figure. How can I achieve this? Does somebody have an idea?
On the following picture, you can see a screenshot of the figure and the highlighted position where the subplot should be created.
Mike

Ameer Hamza on 14 May 2018
Edited: Ameer Hamza on 14 May 2018
If you want to create an axis on the specified location on the figure, just use
ax = axes('Position', [left bottom width height])
this will create an axis starting from the specified lower left corner with specified width and height. It will also return the axes handle ax.
Note that the values are specified in normalized units, i.e. the position values can change from 0 to 1.

Show 1 older comment
Ameer Hamza on 14 May 2018
Why do you need subplot(ax)? You can just plot on this axis using plot(ax, x, y, ...).
"It seems like there is no way, to move the borders of the whole subplots."
Can you show an image example which border you are talking about?
Michael Steinbuechler on 14 May 2018
At first, I would have liked to create the subplots and move them to the highlighted area( in the picture of the question). For now, I will create each plot individually with their own axes.
That's how its supposed to look:
The reason why I would have used subplot at first is that the program I'm writing here can have different plot arrangements. By defining each ax individually (not like the 'grid' that subplot creates), it will take some programming to arrange the plots.
Ameer Hamza on 14 May 2018
If you just want to use subplot instead of axes() then you can still do what you want. For example
% instead of axes() use this.
ax = subplot(121) % 121 is for example
ax.Position = [] % define your position
will work too.