getpixelposition vs OuterPosition of figure

I'm getting different values from getpixelposition and the OuterPosition of the figure ...
get(gcf,'OuterPosition')
ans =
3062 537 2201 801
>> getpixelposition(gcf)
ans =
3070 545 2185 708
>> get(gcf,'Position')
ans =
3070 545 2185 708
What gives? Why is there an 8 pixel discrepancy on each side?
Edit: I added 'Position' to show that this is the same as getpixelposition when units are pixels per Luna's comment. Note that Position is larger than OuterPosition for all properties except the height ...

 채택된 답변

Image Analyst
Image Analyst 2018년 11월 27일

1 개 추천

The larger one probably includes the operating system borders of the figure, while the smaller one does not include the border. That's my guess.

댓글 수: 1

Jim Hokanson
Jim Hokanson 2018년 11월 27일
That appears to be correct, although the border appears to be invisible! It is also unclear what determines border size, as I've seen previous code that hardcoded the size that was incorrect ...
In the mean time I'm launching a temporary figure to determine this discrepancy. It's not ideal but it appears to work. The alternative is to temporarily change the units on the figure of interest but I'm trying to avoid that.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Luna
Luna 2018년 11월 27일
편집: Luna 2018년 11월 27일

1 개 추천

Hi Jim,
I generally set 'units' property as 'normalized' for all figures and uicontrol elements in my codes.
Even the screen resolution changes from one monitor to another the position of your figure window appears in the same position.
get(gcf,'Position') equals to getpixelposition(gcf).
If you use OuterPosition you will get different value.
Position and OuterPosition are different things. Check below to see Position, InnerPosition & OuterPosition.
Also check below link Jan has written:

댓글 수: 6

Jim Hokanson
Jim Hokanson 2018년 11월 27일
Hi Luna,
Thanks for the response but I specifically need the figure position in pixels. getpixelposition was introduced, I think, so that you could get the figure position in pixels without worrying about the units of the figure.
The link is interesting but doesn't actually answer why they are different. In that example the difference is roughly 4.5, but why?
Luna
Luna 2018년 11월 27일
If you read about figure position properties you will see the difference that's why I have sent that link.
Position — Location and size of drawable area
[left bottom width height]
Location and size of the drawable area, specified as a vector of the form [left bottom width height].
This area excludes the figure borders, title bar, menu bar, and tool bars.
OuterPosition Location and size of outer bounds
[left bottom width height]
Location and size of the outer bounds, specified as a vector of the form [left bottom width height].
This property defines the region enclosed by the figure’s outer bounds (which includes the borders, title bar, menu bar, and tool bars).
Image Analyst
Image Analyst 2018년 11월 27일
The help says "The default value of [0 0 1 1] includes the whole interior of the container." but it's not clear if the interior of the container includes the toolbar, which is outside the uniform graph area but inside the outer window border. And the help pictures for OuterPosition aren't exactly helpful:
0000 Screenshot.png
If anything, it looks like the outerposition might not include the toolbar, though it doesn't show a figure window with a toolbar, unfortunately. It would be nice if they were more exact in their description.
Jim Hokanson
Jim Hokanson 2018년 11월 27일
편집: Jim Hokanson 2018년 11월 27일
The outerposition includes the title, toolbar, and menubar.
What's strange is that the 'outerposition' is missing some sort of invisible border that 'position' keeps.
Edit: Nevermind, the outerposition is larger than the position on the sides by the invisible border width ...
Image Analyst
Image Analyst 2018년 11월 27일
But Position (the red line) is inside the Outerposition (blue) so why do you say that? If it's inside the blue, then the outer coordinates of the blue line should take it into account.
Jim Hokanson
Jim Hokanson 2018년 11월 27일
Because I didn't get enough sleep last night and it was only when I was trying to explain it to you that I realized my mistake!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

제품

태그

질문:

2018년 11월 27일

편집:

2018년 11월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by