axes

Creates axes in the current figure and can make existing axes current.

Category: Graphics > Formatting and Annotation

Syntax

axes

Creates default axes and makes them current.

axes('Position', pos)

Creates axes at [left bottom width height] in normalized units.

axes(ax)

Makes the existing axes ax current.

ax = axes(___)

Also returns the axes handle.

Description

Plotting commands draw in the current axes. Creating several axes at chosen positions lets you place plots freely, including an inset inside a larger plot. To pass a target to plotting functions without changing the current axes, give the handle as their first argument, as in plot(ax, x, y).

Input arguments

'Position'
Four-element vector of normalized units, between 0 and 1.
ax
Handle of an existing axes object.

Output arguments

ax
Handle of the axes.

Example

Axes in a chosen position

ax = axes('Position', [0.1 0.1 0.5 0.5]);
plot(ax, 1:5)
disp(ax.Position)
Output
    0.1000    0.1000    0.5000    0.5000

See also

subplot gca figure tiledlayout