How to get the size or position of the plot box within a figure window?

339 ビュー (過去 30 日間)
paul harder
paul harder 2014 年 3 月 6 日
コメント済み: Gert Kruger 2018 年 11 月 7 日
After much effort, I am still struggling to find the command to get the size or position of the plot box (i.e. the white box) within a figure window. What I really need is the aspect ratio of this white box, but a size or position command would get me there. I've tried variations of 'Position', 'PlotBoxAspectRatio', 'pbaspect',and 'DataAspectRatio' without luck.
For example, if I run the following command,
I want to know about the physical size/shape of the white box ONLY, not the grey box:
  1 件のコメント
Mr M.
Mr M. 2018 年 7 月 3 日
and how to get the size of the grey area? Because as far as I know, figure size consist the whole are with title bar also. But I need only the grey 'drawable' area.



Dishant Arora
Dishant Arora 2014 年 3 月 6 日
編集済み: Dishant Arora 2014 年 3 月 6 日
h =figure;
axesHandles = findall(h,'type','axes');
  4 件のコメント
Eric 2017 年 4 月 12 日
Hi Paul,
I'm raising this thread from the grave to ask a question about your algorithm for determining the width and height.
Shouldn't these instead be:
For axesPosition in default normalized units and windowPosition in default pixel units, using your code with a square axis doesn't give an aspect ratio of 1, whereas the two lines I gave does.
I am wondering if there is a situation where your code is actually what is needed and my code is wrong. I can imagine that if axesPosition was not in normalized units, one would have to do something differently.


その他の回答 (1 件)

Hieu Nguyen
Hieu Nguyen 2018 年 2 月 9 日
You can use the subplot function:
pos = [0.3 0.6 0.2 0.4]; % [left bottom width height]
Then, you can plot the figure that you need:
  1 件のコメント
Gert Kruger
Gert Kruger 2018 年 11 月 7 日
Thanks, using subplot is easier...


Community Treasure Hunt

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

Start Hunting!

Translated by