getpixelposition vs OuterPosition of figure

18 Ansichten (letzte 30 Tage)
Jim Hokanson
Jim Hokanson am 27 Nov. 2018
Bearbeitet: Jim Hokanson am 27 Nov. 2018
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 ...

Akzeptierte Antwort

Image Analyst
Image Analyst am 27 Nov. 2018
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 Kommentar
Jim Hokanson
Jim Hokanson am 27 Nov. 2018
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Luna
Luna am 27 Nov. 2018
Bearbeitet: Luna am 27 Nov. 2018
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 Kommentare
Image Analyst
Image Analyst am 27 Nov. 2018
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 am 27 Nov. 2018
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!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by