MATLAB Functions Help Desk

axes

Purpose

Create Axes graphics object

Syntax

Description

axes is the low-level function for creating Axes graphics objects.

axes creates an Axes graphics object in the current Figure using default property values.

axes('PropertyName',PropertyValue,...) creates an Axes object having the specified property values. MATLAB uses default values for any properties that you do not explicitly define as arguments.

h = axes(...) returns the handle of the created Axes object.

axes(h) makes existing axes h the current Axes. It also makes h the first Axes listed in the Figure's Children property and set the Figure's CurrentAxes property to h. The current Axes is the target for functions that draw Image, Line, Patch, Surface, and Text graphics objects.

Remarks

MATLAB automatically creates an Axes, if one does not already exist, when you issue a command that draws Image, Light, Line, Patch, Surface, or Text graphics objects.

The axes function accepts property name/property value pairs, structure arrays, and cell arrays as input arguments (see the set and get reference pages for examples of how to specify these data types). These properties, which control various aspects of the Axes object, are described in the "Axes Properties" section.

Use the 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 current Axes.

The axis (not axes) function provides simplified access to commonly used properties that control the scaling and appearance of Axes.

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.

Stretch-to-fill

By default, MATLAB stretches the Axes to fill the Axes position rectangle (the rectangle defined by the last two elements in the 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 some specific three dimensional aspect ratio. Stretch-to-fill is active when the DataAspectRatioMode, PlotBoxAspectRatioMode, and CameraViewAngleMode are all auto (the default). However, stretch-to-fill is turned off when DataAspectRatio, PlotBoxAspectRatio, or CameraViewAngle are 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 Position rectangle.

When Stretch-to-fill is disabled, MATLAB sets the size of the Axes to be as large as possible within the constraints imposed by the Position rectangle without introducing distortion. In the picture above, the height of the rectangle constrains the Axes size.

Examples

Zooming

Zoom in using aspect ratio and limits:

Zoom in and out using the CameraViewAngle:

Note that both examples disable MATLAB's stretch-to-fill behavior.

Positioning the Axes

The Axes Position property enable you to define the location of the Axes within the Figure window. For example,

creates an Axes object at the specified position within the current Figure and returns a handle to it. Specify the location and size of the Axes with a rectangle defined by a four-element vector,

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.

Object Hierarchy



Setting Property Defaults

You can set default Axes properties on the Figure and Root levels:

Where PropertyName is the name of the Axes property and PropertyValue is the value you are specifying.

Axes Properties

This section lists property names along with the type of values each accepts. Curly braces { } enclose default values.

AmbientLightColor      ColorSpec

The background light in a scene. Ambient light is a directionless light that shines uniformly on all objects in the Axes. However, if there are no visible Light objects in the Axes, MATLAB does not use AmbientLightColor. If there are Light objects in the Axes, the AmbientLightColor is added to the other light sources.

AspectRatio            (Obsolete)

This property produces a warning message when queried or changed. It has been superseded by the DataAspectRatio[Mode] and PlotBoxAspectRatio[Mode] properties.

Box                    on | {off}

Axes box mode. This property specifies whether to enclose the Axes extent in a box for 2-D views or a cube for 3-D views. The default is to not display the box.

BusyAction             cancel | {queue}

Callback routine interruption. The BusyAction property enables you to control how MATLAB handles events that potentially interrupt executing callback routines. If there is a callback routine executing, subsequently invoked callback routes always attempt to interrupt it. If the Interruptible property of the object whose callback is executing is set to on (the default), then interruption occurs at the next point where the event queue is processed. If the Interruptible property is off, the BusyAction property (of the object owning the executing callback) determines how MATLAB handles the event. The choices are:

ButtonDownFcn          string

Button press callback routine. A callback routine that executes whenever you press a mouse button while the pointer is within the Axes, but not over another graphics object displayed in the Axes. For 3-D views, the active area is defined by a rectangle that encloses the Axes.

Define this routine as a string that is a valid MATLAB expression or the name of an M-file. The expression executes in the MATLAB workspace.

CameraPosition         [x, y, z] Axes coordinates

The location of the camera. This property defines the position from which the camera views the scene. Specify the point in Axes coordinates.

If you fix CameraViewAngle, you can zoom in and out on the scene by changing the CameraPosition, moving the camera closer to the CameraTarget to zoom in and farther away from the CameraTarget to zoom out. As you change the CameraPosition, the amount of perspective also changes, if Projection is perspective. You can also zoom by changing the CameraViewAngle, however, this does not change the amount of perspective in the scene.

CameraPositionMode     {auto} | manual

Auto or manual CameraPosition. When set to auto, MATLAB automatically calculates the CameraPosition such that the camera lies a fixed distance from the CameraTarget along the Azimuth and Elevation specified in the View. Setting a value for CameraPosition sets this property to manual.

CameraTarget           [x, y, z] Axes coordinates

Camera aiming point. This property specifies the location in the Axes that the camera points to. The CameraTarget and the CameraPosition define the vector along which the camera looks.

CameraTargetMode       {auto} | manual

Auto or manual CameraTarget placement. When this property is auto, MATLAB automatically positions the CameraTarget at the centroid of the Axes plotbox. Specifying a value for CameraTarget sets this property to manual.

CameraUpVector         [x, y, z] Axes coordinates

Camera rotation. This property specifies the rotation of the camera around the viewing axis defined by the CameraTarget and the CameraPosition properties. Specify CameraUpVector as a three-element array containing the x, y, and z components of the vector. For example, [0 1 0] specifies the positive y-axis as the up direction.

The default CameraUpVector is [0 0 1], which defines the positive z-axis as the up direction.

CameraUpVectorMode     {auto} | manual

Default or user-specified up vector. When CameraUpVectorMode is auto, MATLAB uses a value of [0 0 1] (positive z-direction is up) for 3-D views and [0 1 0] (positive y-direction is up) for 2-D views. Setting a value for CameraUpVector sets this property to manual.

CameraViewAngle        scalar between 0 and 180 (angle in degrees)

The field of view. This property determines the camera field of view. Changing this value affects the size of graphics objects displayed in the Axes, but does not affect the degree of perspective distortion. The greater the angle, the larger the field of view, and the smaller objects appear in the scene.

CameraViewAngleMode    {auto} | manual

Auto or manual CameraViewAngle. When in auto mode, MATLAB sets CameraViewAngle to the minimum angle that captures the entire scene (up to 180°).

The following table summarizes MATLAB's automatic camera behavior.

CameraView Angle

Camera
Target

Camera
Position

Behavior

auto

auto

auto

CameraTarget is set to plot box centroid, CameraViewAngle is set to capture entire scene, CameraPosition is set along the view axis.

auto

auto

manual

CameraTarget is set to plot box centroid, CameraViewAngle is set to capture entire scene.

auto

manual

auto

CameraViewAngle is set to capture entire scene, CameraPosition is set along the view axis.

auto

manual

manual

CameraViewAngle is set to capture entire scene.

manual

auto

auto

CameraTarget is set to plot box centroid, CameraPosition is set along the view axis.

manual

auto

manual

CameraTarget is set to plot box centroid

manual

manual

auto

CameraPosition is set along the view axis.

manual

manual

manual

All Camera properties are user-specified.

Children               vector of graphics object handles

Children of the Axes. A vector containing the handles of all graphics objects rendered within the Axes (whether visible or not). The graphics objects that can be children of Axes are Images, Lights, Lines, Patches, Surfaces, and Text.

The Text objects used to label the x-, y-, and z-axes are also children of Axes, but their HandleVisibility properties are set to callback. This means their handles do not show up in the Axes Children property unless you set the Root ShowHiddenHandles property to on.

CLim                   [cmin, cmax]

Color axis limits. A two-element vector that determines how MATLAB maps the CData values of Surface and Patch objects to the Figure's colormap. cmin is the value of the data mapped to the first color in the colormap, and cmax is the value of the data mapped to the last color in the colormap. Data values in between are linearly interpolated across the colormap, while data values outside are clamped to either the first or last colormap color, whichever is closest.

When CLimMode is auto (the default), MATLAB assigns cmin the minimum data value and cmax the maximum data value in the graphics object's CData. This maps CData elements with the minimum data value to the first colormap entry and with the maximum data value to the last colormap entry.

If the Axes contains multiple graphics objects, MATLAB sets CLim to span the range of all objects' CData.

CLimMode               {auto} | manual

Color axis limits mode. In auto mode, MATLAB sets the CLim property to span the CData limits of the graphics objects displayed in the Axes. If CLimMode is manual, MATLAB does not change the value of CLim when the CData limits of axes children change. Setting the CLim property sets this property to manual.

Clipping               {on} | off

This property has no effect on Axes.

Color                  {none} | ColorSpec

Color of the Axes back planes. Setting this property to none means the Axes is transparent and the Figure color shows through. A ColorSpec is a three-element RGB vector or one of MATLAB's predefined names. See the ColorSpec reference page for more information on specifying color. Note that while the default value is none, the matlabrc.m file may set the Axes color to a specific color.

ColorOrder             m-by-3 matrix of RGB values

Colors to use for multiline plots. An m-by-3 matrix of RGB values that define the colors used by the plot and plot3 functions to color each line plotted. 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. To obtain the current , ColorOrder, which may be set during startup, get the property:

Note that if the Axes NextPlot property is set to replace (the default), high-level functions like plot reset the ColorOrder property before determining the colors to use. If you want MATLAB to use a ColorOrder that is different than the default, set NextPlot to replacedata. You can also specify your own default ColorOrder.

CreateFcn              string

Callback routine executed during object creation. This property defines a callback routine that executes when MATLAB creates an Axes object. You must define this property as a default value for Axes. For example, the statement,

defines a default value on the Root level that sets the current Axes' background color to blue whenever you (or MATLAB) create an Axes. MATLAB executes this routine after setting all properties for the Axes. Setting this property on an existing Axes object has no effect.

The handle of the object whose CreateFcn is being executed is accessible only through the Root CallbackObject property, which can be queried using gcbo.

CurrentPoint           2-by-3 matrix

Location of last button click, in Axes data units. A 2-by-3 matrix containing the coordinates of two points defined by the location of the pointer. These two points lie on the line that is perpendicular to the plane of the screen and passes through the pointer. The 3-D coordinates are the points, in the axes coordinate system, where this line intersects the front and back surfaces of the Axes volume (which is defined by the Axes x, y, and z limits).

The returned matrix is of the form:

MATLAB updates the CurrentPoint property whenever a button-click event occurs. The pointer does not have to be within the Axes, or even the Figure window; MATLAB returns the coordinates with respect to the requested Axes regardless of the pointer location.

DataAspectRatio        [dx dy dz]

Relative scaling of data units. A three-element vector controlling the relative scaling of data units in the x, y, and z directions. For example, setting this property t o [1 2 1] causes the length of one unit of data in the x direction to be the same length as two units of data in the y direction and one unit of data in the z direction.

Note that the DataAspectRatio property interacts with the PlotBoxAspectRatio, XLimMode, YLimMode, and ZLimMode properties to control how MATLAB scales the x-, y-, and z-axis. Setting the DataAspectRatio will disable the Stretch-to-fill behavior, if DataAspectRatioMode, PlotBoxAspectRatioMode, and CameraViewAngleMode were previously all auto. The following table describes the interaction between properties when the Stretch-to-fill behavior is disabled.

X-, Y-, Z-Limits

DataAspect Ratio

PlotBox
AspectRatio

Behavior

auto

auto

auto

Limits chosen to span data range in all dimensions.

auto

auto

manual

Limits chosen to span data range in all dimensions. DataAspectRatio is modified to achieve the requested PlotBoxAspectRatio within the limits selected by MATLAB.

auto

manual

auto

Limits chosen to span data range in all dimensions. PlotBoxAspectRatio is modified to achieve the requested DataAspectRatio within the limits selected by MATLAB.

auto

manual

manual

Limits chosen to completely fit and center the plot within the requested PlotBoxAspectRatio given the requested DataAspectRatio (this may produce empty space around 2 of the 3 dimensions).

manual

auto

auto

Limits are honored. The DataAspectRatio and PlotBoxAspectRatio are modified as necessary.

manual

auto

manual

Limits and PlotBoxAspectRatio are honored. The DataAspectRatio is modified as necessary.

manual

manual

auto

Limits and DataAspectRatio are honored. The PlotBoxAspectRatio is modified as necessary.

1 manual

2 auto

manual

manual

The 2 automatic limits are selected to honor the specified aspect ratios and limit. See "Examples"

2 or 3 manual

manual

manual

Limits and DataAspectRatio are honored; the PlotBoxAspectRatio is ignored.

DataAspectRatioMode    {auto} | manual

User or MATLAB controlled data scaling. This property controls whether the values of the DataAspectRatio property are user defined or selected automatically by MATLAB. Setting values for the DataAspectRatio property automatically sets this property to manual. Changing DataAspectRatioMode to manual will disable the Stretch-to-fill behavior, if DataAspectRatioMode, PlotBoxAspectRatioMode, and CameraViewAngleMode were previously all auto

DeleteFcn              string

Delete Axes callback routine. A callback routine that executes when the Axes object is deleted (e.g., when you issue a delete or a close command). MATLAB executes the routine before destroying the object's properties so the callback routine can query these values.

The handle of the object whose DeleteFcn is being executed is accessible only through the Root CallbackObject property, which can be queried using gcbo.

DrawMode               {normal} | fast

Rendering method. This property controls the method MATLAB uses to render graphics objects displayed in the Axes, when the Figure Renderer is painters.

When the Figure Renderer is zbuffer, DrawMode is ignored, and hidden surface elimination and object intersection handling are always provided.

FontAngle              {normal} | italic | oblique

Select italic or normal font. This property selects the character slant for Axes text. normal specifies a nonitalic font. italic and oblique specify italic font.

FontName               The default is Helvetica on many systems

Font family name. The font family name specifying the font to use for Axes labels. To display and print properly, FontName must be a font that your system supports. Note that the x-, y-, and z-axis labels do not display in a new font until you manually reset them (by setting the XLabel, YLabel, and ZLabel properties or by using the xlabel, ylabel, or zlabel command). Tick mark labels change immediately.

FontSize               Font size specified in FontUnits

Font size. An integer specifying the font size to use for Axes labels and titles, in units determined by the FontUnits property. The default point size is 12. The x-, y-, and z-axis text labels do not display in a new font size until you manually reset them (by setting the XLabel, YLabel, or ZLabel properties or by using the xlabel, ylabel, or zlabel command). Tick mark labels change immediately.

FontUnits              {points} | normalized | inches | centimeters |

                        pixels

Units used to interpret the FontSize property. When set to normalized, MATLAB interprets the value of FontSize as a fraction of the height of the Axes. For example, a normalized FontSize of 0.1 sets the text characters to a font whose height is one tenth of the Axes' height. The default units (points), are equal to 1/72 of an inch.

FontWeight             {normal} | bold | light | demi

Select bold or normal font. The character weight for Axes text. The x-, y-, and z-axis text labels do not display in bold until you manually reset them (by setting the XLabel, YLabel, and ZLabel properties or by using the xlabel, ylabel, or zlabel commands). Tick mark labels change immediately.

GridLineStyle          - | - -| {:} | -. | none

Line style used to draw grid lines. The line style is a string consisting of a character, in quotes, specifying solid lines (-), dashed lines (- -), dotted lines(:), or dash-dot lines (-.). The default grid line style is dotted. To turn on grid lines, use the grid command.

HandleVisibility       {on} | callback | off

Control access to object's handle by command-line users and GUIs. This property determines when an object's handle is visible in its parent's list of children. Handles are always visible when HandleVisibility is on. When HandleVisibility is callback, handles are visible from within callbacks or functions invoked by callbacks, but not from within functions invoked from the command line - a useful way to protect GUIs from command-line users, while permitting their callbacks complete access to their own handles. Setting HandleVisibility to off makes handles invisible at all times - which is occasionally necessary when a callback needs to invoke a function that might potentially damage the UI, and so wants to temporarily hide its own handles during the execution of that function.

When a handle is not visible in its parent's list of children, it can not be returned by any functions which obtain handles by searching the object hierarchy or querying handle properties, including get, findobj, gca, gcf, gco, newplot, cla, clf, and close. When a handle's visibility is restricted using callback or off, the object's handle does not appear in its parent's Children property, Figures do not appear in the Root's CurrentFigure property, objects do not appear in the Root's CallbackObject property or in the Figure's CurrentObject property, and Axes do not appear in their parent's CurrentAxes property.

The Root ShowHiddenHandles property can be set to on to temporarily make all handles visible, regardless of their HandleVisibility settings (this does not affect the values of the HandleVisibility properties).

Handles that are hidden are still valid. If you know an object's handle, you can set and get its properties, and pass it to any function that operates on handles. This property is useful for preventing command-line users from accidently drawing into or deleting a Figure that contains only user interface devices (such as a dialog box).

Interruptible          {on} | off

Callback routine interruption mode. The Interruptible property controls whether an Axes callback routine can be interrupted by subsequently invoked callback routines. Only callback routines defined for the ButtonDownFcn are affected by the Interruptible property. MATLAB checks for events that can interrupt a callback routine only when it encounters a drawnow, figure, getframe, or pause command in the routine. See the EventQueue property for related information.

Setting Interruptible to on allows any graphics object's callback routine to interrupt callback routines originating from an Axes property. Note that MATLAB does not save the state of variables or the display (e.g., the handle returned by the gca or gcf command) when an interruption occurs.

Layer                  {bottom} | top

Draw axis lines below or above graphics objects. This property determines if axis lines and tick marks draw on top or below Axes children objects when the view is [0 90] and the Axes DrawMode is fast (or when there are no Axes Children with nonzero ZData). This enables you to place grid lines and tick marks on top of Images.

LineStyleOrder         LineSpec

Order of line styles and markers used in a plot. This property specifies which line styles and markers to use and in what order when creating multiple-line plots. For example,

sets LineStyleOrder to solid line with asterisk marker, dotted line, and hollow circle marker. The default is (-), which specifies a solid line for all data plotted. Alternatively, you can create a cell array of character strings to define the line styles:

MATLAB supports four line styles, which you can specify any number of times in any order. MATLAB cycles through the line styles only after using all colors defined by the ColorOrder property. For example, the first eight lines plotted use the different colors defined by ColorOrder with the first line style. MATLAB then cycles through the colors again, using the second line style specified, and so on.

You can also specify line style and color directly with the plot and plot3 functions or by altering the properties of the Line objects.

Note that, if the Axes NextPlot property is set to replace (the default), high-level functions like plot reset the LineStyleOrder property before determining the line style to use. If you want MATLAB to use a LineStyleOrder that is different than the default, set NextPlot to replacedata. You can also specify your own default LineStyleOrder.

LineWidth              linewidth in points

Width of axis lines. This property specifies the width, in points, of the x-, y-, and z-axis lines. The default line width is 0.5 points (1 point = inch).

NextPlot               add | {replace} | replacechildren

Where to draw the next plot. This property determines how high-level plotting functions draw into an existing Axes.

The newplot function simplifies the use of the NextPlot property and is used by M-file functions that draw graphs using only low-level object creation routines. See the M-file pcolor.m for an example. Note that Figure graphics objects also have a NextPlot property.

Parent                 Figure handle

Axes parent. The handle of the Axes' parent object. The parent of an Axes object is the Figure in which it is displayed. The utility function gcf returns the handle of the current Axes' Parent. You can reparent Axes to other Figure objects.

PlotBoxAspectRatio     [px py pz]

Relative scaling of Axes plotbox. A three-element vector controlling the relative scaling of the plot box in the x-, y-, and z-directions. The plot box is a box enclosing the Axes data region as defined by the x-, y-, and z-axis limits.

Note that the PlotBoxAspectRatio property interacts with the DataAspectRatio, XLimMode, YLimMode, and ZLimMode properties to control the way graphics objects are displayed in the Axes. Setting the PlotBoxAspectRatio will disable the Stretch-to-fill behavior, if DataAspectRatioMode, PlotBoxAspectRatioMode, and CameraViewAngleMode were previously all auto. .

PlotBoxAspectRatioMode {auto} | manual

User or MATLAB controlled axis scaling. This property controls whether the values of the PlotBoxAspectRatio property are user defined or selected automatically by MATLAB. Setting values for the PlotBoxAspectRatio property automatically sets this property to manual. Changing the PlotBoxAspectRatioMode to manual will disable the Stretch-to-fill behavior, if DataAspectRatioMode, PlotBoxAspectRatioMode, and CameraViewAngleMode were previously all auto.

Position               4-element vector

Position of Axes. A four-element vector specifying a rectangle that locates the Axes within the Figure window. The vector is of the form:

where left and bottom define the distance from the lower-left corner of the Figure window to the lower-left corner of the rectangle. width and height are the dimensions of the rectangle. All measurements are in units specified by the Units property.

When Axes Stretch-to-fill behavior is enabled (when DataAspectRatioMode, PlotBoxAspectRatioMode, CameraViewAngleMode are all auto), the axes are stretched to fill the Position rectangle. When Stretch-to-fill is disabled, the Axes are made as big as possible while obeying all other properties, without extending outside the Position rectangle

Projection             {orthographic} | perspective

Type of projection. This property selects between two projection types:

Selected               on | off

Is object selected. When this property is on. MATLAB displays selection handles if the SelectionHighlight property is also on. You can, for example, define the ButtonDownFcn to set this property, allowing users to select the object with the mouse.

SelectionHighlight     {on} | off

Objects highlight when selected. When the Selected property is on, MATLAB indicates the selected state by drawing four edge handles and four corner handles. When SelectionHighlight is off, MATLAB does not draw the handles.

Tag                    string

User-specified object label. The Tag property provides a means to identify graphics objects with a user-specified label. This is particularly useful when constructing interactive graphics programs that would otherwise need to define object handles as global variables or pass them as arguments between callback routines.

For example, suppose you want to direct all graphics output from an M-file to a particular Axes, regardless of user actions that may have changed the current Axes. To do this, identify the Axes with a Tag:

Then make that Axes the current Axes before drawing by searching for the Tag with findobj:

TickDir                in | out

Direction of tick marks. For 2-D views, the default is to direct tick marks inward from the axis lines; 3-D views direct tick marks outward from the axis line.

TickDirMode            {auto} | manual

Automatic tick direction control. In auto mode, MATLAB directs tick marks inward for 2-D views and outward for 3-D views. When you specify a setting for TickDir, MATLAB sets TickDirMode to manual. In manual mode, MATLAB does not change the specified tick direction.

TickLength             [2DLength 3DLength]

Length of tick marks. A two-element vector specifying the length of Axes tick marks. The first element is the length of tick marks used for 2-D views and the second element is the length of tick marks used for 3-D views. Specify tick mark lengths in units normalized relative to the longest of the visible X-, Y-, or Z-axis annotation lines.

Title                  handle of text object

Axes title. The handle of the Text object that is used for the Axes title. You can use this handle to change the properties of the title Text or you can set Title to the handle of an existing Text object. For example, the following statement changes the color of the current title to red:

To create a new title, set this property to the handle of the Text object you want to use:

However, it is generally simpler to use the title command to create or replace an Axes title:

Type                   string (read only)

Type of graphics object. This property contains a string that identifies the class of graphics object. For Axes objects, Type is always set to 'axes'.

Units                  inches | centimeters | {normalized} | points | pixels

Position units. The units used to interpret the Position property. All units are measured from the lower-left corner of the Figure window. normalized units map the lower-left corner of the Figure window to (0,0) and the upper-right corner to (1.0, 1.0). inches, centimeters, and points are absolute units (one point equals of an inch).

UserData               matrix

User specified data. This property can be any data you want to associate with the Axes object. The Axes does not use this property, but you can access it using the set and get functions.

View                   Obsolete

The functionality provided by the View property is now controlled by the Axes camera properties - CameraPosition, CameraTarget, CameraUpVector, and CameraViewAngle. See the view command.

Visible                {on} | off

Visibility of Axes. By default, Axes are visible. Setting this property to off prevents axis lines, tick marks, and labels from being displayed. The visible property does not affect children of Axes.

XAxisLocation          top | {bottom}

Location of x-axis tick marks and labels. This property controls where MATLAB displays the x-axis tick marks and labels. Setting this property to top moves the x-axis to the top of the plot.

YAxisLocation          right | {left}

Location of y-axis tick marks and labels. This property controls where MATLAB displays the y-axis tick marks and labels. Setting this property to right moves the y-axis to the right side of the plot.

Properties That Control the X-, Y-, or Z-Axis

XColor, YColor, ZColor ColorSpec.

Color of axis lines. A three-element vector specifying an RGB triple, or a predefined MATLAB color string. This property determines the color of the axis lines, tick marks, tick mark labels, and the axis grid lines of the respective x-, y-, and z-axis. The default axis color is white. See the ColorSpec reference page for details on specifying colors.

XDir, YDir, ZDir       {normal} | reverse

Direction of increasing values. A mode controlling the direction of increasing axis values. Axes form a right-hand coordinate system. By default,

XGrid, YGrid, ZGrid    on | {off}

Axis gridline mode. When you set any of these properties to on, MATLAB draws grid lines perpendicular to the respective axis (i.e., along lines of constant x, y, or z values). Use the grid command to set all three properties on or off at once.

XLabel, YLabel, ZLabel handle of text object

Axis labels. The handle of the Text object used to label the x, y, or z-axis, respectively. To assign values to any of these properties, you must obtain the handle to the text string you want to use as a label. This statement defines a Text object and assigns its hanlde to the XLabel property:

MATLAB places the string 'axis label' appropriately for an x-axis label. Any Text object whose handle you specify as an XLabel, YLabel, or ZLabel property is moved to the appropriate location for the respective label.

Alternatively, you can use the xlabel, ylabel, and zlabel functions, which generally provide a simpler means to label axis lines.

XLim, YLim, ZLim       [minimum maximum]

Axis limits. A two-element vector specifying the minimum and maximum values of the respective axis.

Changing these properties affects the scale of the x-, y-, or z-dimension as well as the placement of labels and tick marks on the axis. The default values for these properties are [0 1].

XLimMode, YLimMode, ZLimMode{auto} | manual

MATLAB or user-controlled limits. The axis limits mode determines whether MATLAB calculates axis limits based on the data plotted (i.e., the XData, YData, or ZData of the Axes children) or uses the values explicitly set with the XLim, YLim, or ZLim property, in which case, the respective limits mode is set to manual.

XScale, YScale, ZScale {linear} | log

Axis scaling. Linear or logarithmic scaling for the respective axis.

XTick, YTick, ZTick    vector of data values locating tick marks

Tick spacing. A vector of x-, y-, or z-data values that determine the location of tick marks along the respective axis. If you do not want tick marks displayed, set the respective property to the empty vector, [ ]. These vectors must contain monotonically increasing values.

XTickLabel, YTickLabel, ZTickLabelstring

Tick labels. A matrix of strings to use as labels for tick marks along the respective axis. These labels replace the numeric labels generated by MATLAB. If you do not specify enough text labels for all the tick marks, MATLAB uses all of the labels specified, then reuses the specified labels.

For example, the statement,

labels the first four tick marks on the x-axis and then reuses the labels until all ticks are labeled.

Labels can be specified as cell arrays of strings, padded string matrices, string vectors separated by vertical slash characters, or as numeric vectors (where each number is implicitly converted to the equivalent string using num2str). All of the following are equivalent:

XTickMode, YTickMode, ZTickMode{auto} | manual

MATLAB or user controlled tick spacing. The axis tick modes determine whether MATLAB calculates the tick mark spacing based on the range of data for the respective axis (auto mode) or uses the values explicitly set for any of the XTick, YTick, and ZTick properties (manual mode). Setting values for the XTick, YTick, or ZTick properties sets the respective axis tick mode to manual.

XTickLabelMode, YTickLabelMode, ZTickLabelMode{auto} | manual

MATLAB or user determined tick labels. The axis tick mark labeling mode determines whether MATLAB uses numeric tick mark labels that span the range of the plotted data (auto mode) or uses the tick mark labels specified with the XTickLabel, YTickLabel, or ZTickLabel property (manual mode). Setting values for the XTickLabel, YTickLabel, or ZTickLabel property sets the respective axis tick label mode to manual.

See Also

axis, cla, clf, figure, gca, subplot



[ Previous | Help Desk | Next ]