h = axes
axes(h)
h = axes('PropertyName',PropertyValue,...)
axes
is a low-level function for creating axes objects. Axes objects are children of figure objects and parents of image, line, patch, surface, and text objects. Axes objects define a frame of reference that orients their children objects within the figure.
h = axes
creates the default full-window axes and returns its handle.
axes(h)
makes the axes with handle h
the current axes.
h = axes('PropertyName',PropertyValue,...)
is an object creation function that accepts property name/property value pairs as input arguments. These properties, which control various aspects of axes objects, are described under "Object Properties." You can also set and query property values after creation using the set
and get
functions.
Specify default axes properties at the axes' parent level, that is, at the figure object. To do so, call the set
function, supplying as arguments the handle of the parent figure, a default name string, and the desired default value. Construct the default name string by prepending the string 'DefaultAxes'
to the desired axes property name. For example
set(fig_handle,'DefaultAxesColor','red')
sets the default axes rectangle color to red for all axes created in the figure with handle fig_handle
.
The axis
(not axes
) function provides simplified access to commonly used properties that control the scaling and appearance of axes.
Use gca
(get current axes) to obtain the handle of the current axes.
AspectRatio
[axis_ratio data_ratio]
, where axis_ratio
is the ratio of the length of the horizontal axis to the length of the vertical axis (width divided by height). MATLAB creates the largest axes with this ratio that fits into the rectangle defined by Position
.data_ratio
is the ratio of the length of a data unit along the horizontal axis to the length of a data unit along the vertical axis. To create axes with this data_ratio
, MATLAB changes the limits of one axis while maintaining the ratio specified in axis_ratio
. This change does not affect the corresponding limits property (XLim
or YLim
).0,Inf
]. The default for both is NaN
, which specifies no ratio. By default, MATLAB changes either ratio in order create an axes that best fills the figure window.Box
on
Enclose graphics area in box (2-D) or cube (3-D).off
(Default.) Do not display enclosing box.ButtonDownFcn
Callback string, object selection.
eval
function to execute the specified function. Initially the empty matrix.Children
CLim
[cmin cmax]
that determines how MATLAB maps data values to the colormap. cmin
is the data value to map to the first colormap entry, and cmax
is the data value to map to the last colormap entry. By default Clim
is [0 1], mapping the full range of the colormap to the full range of the data.cmin
are mapped to cmin
and data values greater than cmax
are mapped to cmax
. NaN
s are clipped by making them transparent. CLim
values outside the range of the data cause MATLAB to use a limited portion of the colormap.CLim
affects the rendering of surface and patch objects, but not images, lines, or text.CLimMode
auto
(Default.) MATLAB calculates color limits that span the full range of the data of the axes' children.manual
Color limits do not automatically change (see the CLim
property). Setting values for CLim
sets this property to manual
.Clipping
Data clipping.
on
(Default.) No effect for axes objects.off
No effect for axes objects.Color
ColorSpec
A three-element RGB vector or one of MATLAB's predefined names. See the
ColorSpec reference page for more information on specifying color. none
(Default.) The same as the figure background color.ColorOrder
Axes color order.
m
-by-3 matrix of RGB values. If you do not specify a line color with plot
and plot3
, these functions cycle through the ColorOrder
to obtain the color for each line plotted. By default, ColorOrder
contains the first six colors in MATLAB's predefined color palette: CurrentPoint
3-D coordinates for a pair of points in the axes' data space.
[xback yback zback; xfront yfront zfront]
Units
property.CurrentPoint
property.DrawMode
normal
(Default.) Draw objects from back to front based on the current view.fast
Draws objects in the order in which you originally specified them. This disables the three-dimensional sorting usually performed by MATLAB, resulting in faster rendering.FontAngle
normal
(Default.) Regular font angle.italic
Italics.oblique
Italics on some systems.FontAngle
property.FontName
XLabel
, YLabel
, and ZLabel
properties). The default font is Helvetica.FontSize
FontWeight
normal
(Default.) Regular font weight.bold
Bold weight.GridLineStyle
-
), dashed lines (-
-
), dotted lines(:
), or dash-dot lines (-
.). The default grid line style is dotted.Interruptible
Callback interruptibility.
yes
The callback specified by ButtonDownFcn
is interruptible by other callbacks.no
(Default.) The ButtonDownFcn
callback is not interruptible.Interruptible
property.LineStyleOrder
Axes line style order.
'linestyle1|linestyle2...'
linestyle
is a character string specifying solid lines (-
), dashed lines (-
-
), dotted lines(:
), or dash-dot lines(-.
). The default line style order is solid lines only. Some plotting functions, such as plot
, overrule this property with their own default line style order.LineWidth
NextPlot
new
Create a new axes before drawing.add
Add new objects to the current axes. Setting hold
to on
sets NextPlot
to add
.replace
(Default.) Destroy the current axes (and its contents) and create a new axes at the same position before drawing. Setting hold
to off
sets NextPlot
to replace
.plot
, plot3
, fill
, fill3
, and the M-file graphing functions mesh
, surf
, bar
, and so on. The M-file newplot
is a preamble for handling the NextPlot
property. M-file graphing functions like mesh
, surf
, and bar
call newplot
to control this property before drawing their respective graphs. When creating M-files that implement graphing commands, use newplot
at the beginning of the file. See the M-file pcolor
for an example. Also see the NextPlot
property of figure objects.Parent
gcf
also returns the handle of the current axes' parent figure.Position
[left bottom width height]
, where left
and bottom
are the distance from the lower-left corner of the figure window to the lower-left corner of the axes. width
and height
are the dimensions of the axes rectangle. All measurements are in units specified by the Units
property.TickDir
in
Tick marks are directed inward from the axis lines (default for 2-D plotting).out
Tick marks are directed outward from the axis lines (default for three-dimensional plotting functions unless hold
is on
).TickLength
[2Dlength 3Dlength]
that specifies the length of the axes' tick marks, where2Dlength
is the length of tick marks used for two-dimensional views.3Dlength
is the length of tick marks used for three-dimensional views.Title
set(gca,'title',text(0,0,'axes title'))
text
function requires location data, it is not used to place the text. Instead, MATLAB centers the string 'axes title'
above the axes.title
function provides a simpler means to create a title by encapsulating this procedure.Type
Type of graphics object.
'axes'
for an axes object.Units
pixels
Screen pixels.normalized
(Default.) Normalized coordinates. The lower-left corner of the figure window maps to (0,0) and the upper-right corner to (1.0,1.0).inches
Inches.cent
Centimeters.points
Points. Each point is equivalent to 1/72 of an inch.Units
, return it to its default value after completing your computation so as not to affect other functions that assume Units
is set to the default value.UserData
get
command.
View
[az,el]
, that establishes a viewpoint used to transform three-dimensional plots into the two-dimensional space of the screen. The viewpoint is the location of the eye of an observer looking at the three-dimensional plot, where az
is the azimuth. The azimuth revolves around the z-axis, with positive values causing the viewpoint to rotate in a counter-clockwise direction.el
is the elevation. The elevation specifies an angle above or below the object. Positive values of elevation cause the viewpoint to move above the object (that is, to look down on it); negative values cause the viewpoint to move below the object.View
property alters the XForm
property's transformation matrix. The default View
vector is [0 90].Visible
on
(Default.) Axes lines, tick marks, and labels are visible on the screen.off
Axes lines, tick marks, and labels are not drawn.Visible
property.XForm
View
property.View
property changes XForm
as well. XForm
, however, can define views that you cannot define using only azimuth and elevation (such as perspective views). It is also possible to specify scaling and translations in the same matrix. Such transforms are discussed in most books on computer graphics. The default XForm
matrix is the 4-by-4 identity matrix.XColor
ColorSpec
reference page for details on specifying colors.XDir
normal
(Default.) X values increase from left to right (right-handed coordinate system).reverse
X values increase from right to left.XGrid
on
MATLAB draws grid lines perpendicular to the x-axis at each tick mark (i.e., along lines of constant x values).off
(Default.) Grid lines are not drawn.XLabel
set(gca,'xlabel',text(0,0,'axis label'))
text
function requires location data, it is not used to place the text. Instead, MATLAB places the string 'axis label'
appropriately for an x-axis label.xlabel
function provides a simpler means to label the x-axis by encapsulating this procedure.XLim
[xmin xmax]
that specifies the minimum and maximum x-axis values, wherexmin
is the minimum x-axis value.xmax
is the maximum x-axis value.XLim
affects the scale of the x-dimension as well as the placement of labels and tick marks on the x-axis. The default for XLim
is [0 1].XLimMode
auto
(Default.) MATLAB calculates x-axis limits (XLim
) that span the XData
of the axes' children and produce round numbers for the x-axis limits.manual
MATLAB takes x-axis limits from XLim
; the limits do not depend on the XData
in the children objects. Setting values for XLim
sets this property to manual
.XScale
X-axis scaling.
linear
(Default.) Linear scaling for the x-axis.log
Logarithmic scaling for the x-axis.XTick
XTic
k to the empty vector, []
.XTickLabelMode
auto
(Default.) MATLAB calculates x-axis tick labels (XTickLabels
) that span the XData
of the axes' children.manual
MATLAB takes x-axis tick labels from XTickLabels
; it does not depend on the XData
in the children objects. Setting values for XTickLabels
sets this property to manual
.XTickLabels
set(gca,'XTickLabels',['Old Data';'New Data'])
'Old Data'
and 'New Data'
respectively. Each character string must have an equal number of characters because of the way MATLAB stores strings.XTickMode
auto
(Default.) MATLAB calculates x-axis tick mark spacing (XTick
) that spans the XData
of the axes' children.manual
MATLAB takes x-axis tick spacing from XTick
; it does not depend on the XData
in the children objects. Setting values for XTick
sets this property to manual
.YColor
ColorSpec
reference page for details on specifying colors.YDir
normal
(Default.) Y values increase from bottom to top (right-handed coordinate system).reverse
Y values increase from top to bottom.YGrid
on
MATLAB draws grid lines perpendicular to the y-axis at each tick mark (i.e., along lines of constant y values).off
(Default.) Grid lines are not drawn.YLabel
set(gca,'ylabel',text(0,0,'axis label'))
text
function requires location data, it is not used to place the text. Instead, MATLAB places the string 'axis label'
appropriately for a y-axis label.ylabel
function provides a simpler means to label the y-axis by encapsulating this procedure.YLim
[ymin ymax]
that specifies the minimum and maximum y-axis values, whereymin
is the minimum y-axis value.ymax
is the maximum y-axis value.YLim
affects the scale of the y-dimension as well as the placement of labels and tick marks on the y-axis. The default for YLim
is [0 1].YLimMode
auto
(Default.) MATLAB calculates y-axis limits (YLim
) that span the YData
of the axes' children and produce round numbers for the y-axis limits.manual
MATLAB takes y-axis limits from YLim
; the limits do not depend on the YData
in the children objects. Setting values for YLim
sets this property to manual
.YScale
Y-axis scaling.
linear
(Default.) Linear scaling for the y-axis.log
Logarithmic scaling for the y-axis.YTick
YTic
k to the empty vector, []
.YTickLabelMode
auto
(Default.) MATLAB calculates y-axis tick labels (YTickLabels
) that span the YData
of the axes' children.manual
MATLAB takes y-axis tick labels from YTickLabels
; it does not depend on the YData
in the children objects. Setting values for YTickLabels
sets this property to manual
.YTickLabels
set(gca,'YTickLabels',['Old Data';'New Data'])
'Old Data'
and 'New Data'
respectively. Each character string must have an equal number of characters because of the way MATLAB stores strings.YTickMode
auto
(Default.) MATLAB calculates y-axis tick mark spacing (YTick
) that spans the YData
of the axes' children.manual
MATLAB takes y-axis tick spacing from YTick
; it does not depend on the YData
in the children objects. Setting values for YTick
sets this property to manual
.ZColor
ColorSpec
reference page for details on specifying colors.ZDir
normal
(Default.) Z values increase pointing out of the screen (two-dimensional) or from bottom to top (three-dimensional), corresponding to a right-handed coordinate system.reverse
Z values increase pointing into the screen (two-dimensional) or from top to bottom (three-dimensional).ZGrid
on
MATLAB draws grid lines perpendicular to the z-axis at each tick mark (i.e., along lines of constant z values).off
(Default.) Grid lines are not drawn.ZLabel
set(gca,'zlabel',text(0,0,'axis label'))
text
function requires location data, it is not used to place the text. Instead, MATLAB places the string 'axis label'
appropriately for a z-axis label.zlabel
function provides a simpler means to label the z-axis by encapsulating this procedure.ZLim
[zmin zmax]
that specifies the minimum and maximum z-axis values, wherezmin
is the minimum z-axis value.zmax
is the maximum z-axis value.ZLim
affects the scale of the z-dimension as well as the placement of labels and tick marks on the z-axis. The default for ZLim
is [0 1].ZLimMode
auto
(Default.) MATLAB calculates z-axis limits (ZLim
) that span the ZData
of the axes' children and produce round numbers for the z-axis limits.manual
MATLAB takes z-axis limits from ZLim
; the limits do not depend on the ZData
in the children objects. Setting values for ZLim
sets this property to manual
.ZScale
Z-axis scaling.
linear
(Default.) Linear scaling for the z-axis.log
Logarithmic scaling for the z-axis.ZTick
ZTic
k to the empty vector, []
.ZTickLabelMode
auto
(Default.) MATLAB calculates z-axis tick labels (ZTickLabels
) that span the ZData
of the axes' children.manual
MATLAB takes z-axis tick labels from ZTickLabels
; it does not depend on the ZData
in the children objects. Setting values for ZTickLabels
sets this property to manual
.ZTickLabels
set(gca,'ZTickLabels',['Old Data';'New Data'])
'Old Data'
and 'New Data'
respectively. Each character string must have an equal number of characters because of the way MATLAB stores strings.ZTickMode
auto
(Default.) MATLAB calculates z-axis tick mark spacing (ZTick
) that spans the ZData
of the axes' children.manual
MATLAB takes z-axis tick spacing from ZTick
; it does not depend on the ZData
in the children objects. Setting values for ZTick
sets this property to manual
.Position
. It allows you to define the location of the axes within the figure window. For example,
h = axes('Position',rect)
creates an axes object at the specified position within the current figure window and returns a handle to it. You specify the location and size of the axes with a rectangle defined by a four element vector,
rect = [left, bottom, width, height]
The left
and bottom
elements of this vector define the distance from the lower-left corner of the figure to the lower-left corner of the rectangle. The width
and height
elements define the dimensions of the rectangle. You specify these values in units determined by the Units
property. By default, MATLAB uses normalized units where (0,0) is the lower-left corner and (1.0,1.0) is the upper-right corner of the figure window.You can define multiple axes in a single figure window:
In this example, the first plot occupies the bottom two-thirds of the figure, and the second occupies the top third.clf
axes('position',[.1 .1 .8 .6])
mesh(peaks(20));
axes('position',[.1 .7 .8 .2])
pcolor([1:10;1:10]);
axis
,cla
,clf
,figure
,gca
,subplot
(c) Copyright 1994 by The MathWorks, Inc.