This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


(App Designer) Create UI axes for plots in App Designer

Use only for creating App Designer UI axes. GUIDE creates axes using the axes function. For details, see Graphics Support in App Designer.


ax = uiaxes
ax = uiaxes(Name,Value)
ax = uiaxes(parent)
ax = uiaxes(parent,Name,Value)



ax = uiaxes creates UI axes in a new UI figure window and returns the UIAxes object.


ax = uiaxes(Name,Value) specifies UIAxes property values using one or more Name,Value pair arguments.


ax = uiaxes(parent) creates the UI axes in the specified parent container. The parent must be a Figure created using the uifigure function, or one of its child containers: Tab, Panel, or ButtonGroup

ax = uiaxes(parent,Name,Value) specifies UIAxes property values using one or more Name,Value arguments.


collapse all

Create a line plot and a scatter plot in UI axes.

Create a UI figure window with UI axes and assign the UIAxes object to the variable ax. Add a line plot to the axes by specifying the UIAxes object as the first input argument for the plot function.

fig = uifigure;
ax = uiaxes(fig);
x = linspace(-pi,pi,50);
y = 5*sin(x);

Set the hold state on and add a scatter plot. Specify the UIAxes object as the first input argument for the hold and scatter functions.

y2 = 5*sin(x) + randn(1,50);

Modify the appearance of the UI axes by setting properties using name-value pair arguments. For example, reverse the x-axis direction using the XDir name-value pair.

fig = uifigure;
ax = uiaxes(fig,'XDir','reverse');
x = linspace(-pi,pi);
y = sin(x);

Alternatively, specify properties after the axes is created using dot notation. For example, reverse the y-axis direction using dot notation to access the YDir property.

ax.YDir = 'reverse';

Specify the UI axes position by setting the Position property. Specify the position in pixels.

fig = uifigure;
ax = uiaxes(fig,'Position',[10 10 550 400]);

Add UI axes to a panel within a UI figure window. Specify the panel and axes positions in pixels.

fig = uifigure;
p = uipanel(fig,'Position',[10 10 400 400]);
ax = uiaxes(p,'Position',[10 10 390 390]);

Input Arguments

collapse all

UI axes parent container, specified as a Figure created using the uifigure function, or one of its child containers: Tab, Panel, or ButtonGroup.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Xscale','linear','YScale','log'

The properties list here are only a subset. For a full list, see UIAxes Properties.

collapse all

Minimum and maximum limits, specified as a two-element vector of the form [min max], where max is greater than min. You can specify the limits as numeric, categorical, datetime, or duration values. However, the type of values that you specify must match the type of values along the axis.

You can specify both limits or you can specify one limit and let the axes automatically calculate the other. For an automatically calculated minimum or maximum limit, use -inf or inf, respectively.

Example: ax.XLim = [0 10]

Example: ax.YLim = [-inf 10]

Example: ax.ZLim = [0 inf]

Alternatively, use the xlim, ylim, and zlim functions to set the limits.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | datetime | duration

Scale of values along axis, specified as 'linear' or 'log'.

Example: ax.XScale = 'linear'

Example: ax.YScale = 'log'

Line style used for grid lines, specified as one of the line styles in this table.

Line StyleDescriptionResulting Line
'-'Solid line

'--'Dashed line

':'Dotted line

'-.'Dash-dotted line

'none'No lineNo line

To display the grid lines, use the grid on command or set the XGrid, YGrid, or ZGrid property to 'on'.

Example: ax.GridLineStyle = '--'

Size and location of axes, including the labels and margins, specified as a four-element vector of the form [left bottom width height]. This vector defines a rectangle that encloses the outer bounds of the axes. The left and bottom elements define the position of the rectangle, measured from the lower left corner to the lower left corner of the parent container. The width and height define the size of the rectangle. The values are measured in units determined by the Units property. By default, the units are pixels.

Output Arguments

collapse all

UIAxes object. Use ax to set properties of the UIAxes after they are created.


  • On Windows® systems, UI axes do not support line width values greater than 0.6 points. If you try to set the line width for objects in the UI axes to a value greater than 0.6 points, then MATLAB® returns a warning message and uses 0.6. The line width limit can vary depending on the Windows system display scaling value.

See Also



Introduced in R2016a

Was this topic helpful?