4.5 | 2 ratings Rate this file 18 Downloads (last 30 days) File Size: 5.45 KB File ID: #13927
image thumbnail




12 Feb 2007 (Updated )

Two flexible wrappers to manage graphics object position.

Editor's Notes:

This was a File Exchange Pick of the Week

| Watch this File

File Information

SETPOS/GETPOS are two flexible wrappers to set/get the "Position" property of graphics objects (figure, axes, uicontrol).

SETPOS(H,POS) works as SET(H,'Position',POS) and GETPOS(H) works as GET(H,'Position') but :

Both can set/get data using different unit for each element of the 'Position' vector.

Both can manage each element [Left,Bottom,Width,Height] individually without the others.

Both can use any graphics object HREF as position reference, instead of the parent of H. (Added in V1.1)

SETPOS contains a +/- feature that increase/decrease the corresponding value in the 'Position' vector.

Please contact me directly by email for bug report or enhancement request.


 (Both) 1.0 (12-Feb-2007)

 (Both) 1.1 (14-Feb-2007)
 Third input argument HREF added.
 Minor corrections in the help section.

 (Both) 1.2 (21-Feb-2007)
 Bug fixed if HREF is the Root object.
 Examples removed from the help section.
 Third file containing examples added.


Getinunits inspired this file.

This file inspired Rosin Rammler Diagram Plotting Tool and Legendflex: A More Flexible Legend.

MATLAB release MATLAB 6.1 (R12.1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
12 Apr 2013 Jim

(This comment and the one following both apply to the getpos function only.)

In the fragment:

% Don't use HREF position if it is the parent of H
if href~=get(h,'parent')

the line "href=h;" appears erroneous. After removal, the function works as I expected it to.

11 Apr 2013 Jim

Very nicely done. Unfortunately I think there's an issue when finding positions relative to reference object. The line:

pos(n) = temp(n) - temp_href(n) * flag_href;

is correct for n = 1 or 2 (left & bottom elements of the position vector), but doesn't seem to make sense for n = 3 or 4 (width and height). Stating an object's position relative to a non-parent reference object should only affect location, not size, when working with absolute units (or "nz" if we assume everything's normalized to the same figure). And if the intent was to return object height & width relative to a reference object (for normalized units), the above line isn't the correct way to find them.

22 Feb 2007 Jos x@y.z

I have to take back my comment about the naming conflict: setpos is a private function of the SP toolbox.

17 Feb 2007 Jos x@y.z

Quite usefull. Well done. Good help, albeit what long.
There is a possible name class with setpos in the signal toolbox.

12 Feb 2007 Peter (PB) Bodin

Very useful utility. H1-line, error checking, cleanly written and well commented code. Well done.

15 Feb 2007

Third input argument HREF added.
Some minor corrections in the help section

16 Feb 2007

Add in the description

Contact us