This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

movegui

Move figure to specified location on screen

Syntax

movegui(f,position)
movegui(position)
movegui(f)
movegui

Description

example

movegui(f,position) moves the figure f to the specified screen location. The figure can be one created with either the figure or uifigure function. The position can be specified as a two-element vector or as a predefined position name.

example

movegui(position) moves the current figure or the callback figure to the specified position. To determine the current figure or the callback figure use gcf or gcbf, respectively. Note that gcf and gcbf return figures created with the figure function only. If one does not exist, MATLAB® creates one using figure and moves it to the specified position.

example

movegui(f) moves the figure to the closest position that puts it entirely on screen.

movegui moves the current figure (gcf) or the callback figure (gcbf) to the closest position that puts it entirely on screen.

Examples

collapse all

Create a figure and move it so that the bottom left corner is 300 pixels from the left side of the screen and 600 pixels from the bottom.

fig = uifigure;
movegui(fig,[300 600]);

Create a figure and move it to the bottom center of the screen.

f = figure;
movegui(f,'south');
f1 = figure;
f2 = figure;
movegui('east');

f2 moves because it is the current figure.

Create a figure that is positioned far outside the upper rightmost corner of the screen. Then, move it onscreen.

f = figure('Position',[10000 10000 400 300]);
movegui(f);

The figure moves to the top right corner of the screen because that is the position that is closest to its last location.

Input Arguments

collapse all

Figure, specified as a Figure object created with either the figure or uifigure function. Use this argument to specify a figure you want to move.

Position of the figure on the screen, specified as a two-element numeric vector, a character vector, or a string scalar. A numeric vector specifies x- and y-values in pixels, and a text argument specifies one of the predefined position names.

Example: movegui(f,[150 -50])

Example: movegui('west')

To indicate the offset of the figure from the edges of the screen in units of pixels, specify a two-element numeric vector, [x y]. The edge of the screen that the offset is measured from depends on the sign of the vector element.

Position Vector ElementValue RangeDescription
xx >= 0Offset of left side from left edge of screen
x < 0Offset of right side from right edge of screen
yy >= 0Offset of bottom from bottom edge of screen
y < 0Offset of top from top edge of screen

You can also specify position as one of these position names.

Position NameScreen Location
'north'Top center
'south'Bottom center
'east'Right center
'west'Left center
'northeast'Top right corner
'northwest'Top left corner
'southeast'Bottom right corner
'southwest'Bottom left corner
'center'Center
'onscreen'Location nearest to the current location that is entirely on screen

More About

collapse all

Pixels

Distances in pixels are independent of your system resolution on Windows® and Macintosh systems:

  • On Windows systems, MATLAB defines a pixel as 1/96th of an inch.

  • On Macintosh systems, MATLAB defines a pixel as 1/72nd of an inch.

On Linux® systems, your system resolution determines the size of a MATLAB pixel. For more information, see DPI-Aware Behavior in MATLAB.

Algorithms

collapse all

Use with Maximized Figures

Applying movegui to a maximized figure window moves the window towards the taskbar and creates a gap on the opposite side of the screen about as wide as the task bar. The window might shrink in size by a few pixels. If you use the onscreen option with a maximized figure window, then movegui creates a gap on both the left and upper sides of the screen so that the top left corner of the figure is visible.

See Also

|

Introduced before R2006a