MATLAB Answers

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

871 views (last 30 days)
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.
Thanks in advance,
Mike

  0 Comments

Sign in to comment.

Accepted Answer

Ameer Hamza
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.

  4 Comments

Show 1 older comment
Ameer Hamza
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
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
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.

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Release

R2018a