Create axes graphics object
h = axes(...)
For a list of properties, see Axes Properties.
axes creates an axes graphics
object in the current figure using default property values.
the low-level function for creating axes graphics objects. MATLAB® automatically
creates an axes, if one does not already exist, when you issue a command
that creates a graph.
an axes object having the specified property values. For a description
of the properties, see Axes Properties. MATLAB uses
default values for any properties that you do not explicitly define
as arguments. The
axes function accepts property
name/property value pairs, structure arrays, and cell arrays as input
arguments (see the
get commands for examples of how to specify
these data types). While the basic purpose of an axes object is to
provide a coordinate system for plotted data, axes properties provide
considerable control over the way MATLAB displays data.
axes(parent,...) creates the axes in the
figure, uipanel, or uitab specified by
instead of in the current figure.
axes(h) makes existing axes
current axes and brings the figure containing it into focus. It also
h the first axes listed in the figure's
and sets the figure's
CurrentAxes property to
The current axes is the target for functions that draw image, line,
patch, rectangle, surface, and text graphics objects.
If you want to make an axes the current axes without changing
the state of the parent figure, set the
of the figure containing the axes:
This command is useful if you want a figure to remain minimized or stacked below other figures, but want to specify the current axes.
h = axes(...) returns the
handle of the created axes object.
set function to modify the properties
of an existing axes or the
get function to query
the current values of axes properties. Use the
gca command to obtain the handle of the
function provides simplified access to commonly used properties that
control the scaling and appearance of axes.
PropertyNameis the name of the axes property and
PropertyValueis the value you are specifying. Use
getto access axes properties.
By default, MATLAB stretches the axes to fill the axes
position rectangle (the rectangle defined by the last two elements
Position property). This results in graphs
that use the available space in the rectangle. However, some 3-D graphs
(such as a sphere) appear distorted because of this stretching, and
are better viewed with a specific three-dimensional aspect ratio.
Stretch-to-fill is active when the
CameraViewAngleMode are all auto (the default).
However, stretch-to-fill is turned off when the
CameraViewAngle is user-specified, or when
one or more of the corresponding modes is set to manual (which happens
automatically when you set the corresponding property value).
This picture shows the same sphere displayed both with and without the stretch-to-fill. The dotted lines show the axes rectangle.
When stretch-to-fill is disabled, MATLAB sets the size
of the axes to be as large as possible within the constraints imposed
Position rectangle without introducing distortion.
In the picture above, the height of the rectangle constrains the axes
Create a figure with two axes. Specify the position of the first axes so that it has a lower left corner at the point (0.1 0.1) with a width and height of 0.7. Specify the position of the second axes so that it has a lower left corner at the point (0.65 0.65) with a width and height of 0.28. By default, the values are normalized to the figure. Return the axes objects as
figure ax1 = axes('Position',[0.1 0.1 0.7 0.7]); ax2 = axes('Position',[0.65 0.65 0.28 0.28]);
Add a plot to each axes. Specify the axes for the plot by passing the axes object as the first input argument to the graphics function. Most graphics functions reset some axes properties, such as the tick values and labels. However, they do not reset the axes position.
To create a figure select New > Figure from the figure window File menu. To add an axes to a figure, click one of the New Subplots icons in the Figure Palette, and slide right to select an arrangement of new axes. For details, see Customize Graph Using Plot Tools.