Documentation

uiaxes

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

Use only for creating App Designer UI axes.GUIDE creates axes using theaxesfunction. For details, seeGraphics Support in App Designer.

Syntax

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

Description

example

ax= uiaxescreates UI axes in a new UI figure window and returns theUIAxesobject.

example

ax= uiaxes(Name,Value)specifiesUIAxesproperty values using one or moreName,Valuepair arguments.

example

ax= uiaxes()creates the UI axes in the specified parent container. The parent must be aFigurecreated using theuifigurefunction, or one of its child containers:Tab,Panel, orButtonGroup

ax= uiaxes(,Name,Value)specifiesUIAxesproperty values using one or moreName,Valuearguments.

Examples

collapse all

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

Create a UI figure window with UI axes and assign theUIAxesobject to the variableax. Add a line plot to the axes by specifying theUIAxesobject as the first input argument for theplotfunction.

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

Set the hold state on and add a scatter plot. Specify theUIAxesobject as the first input argument for theholdandscatterfunctions.

hold(ax,'on') y2 = 5*sin(x) + randn(1,50); scatter(ax,x,y2)

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

fig = uifigure; ax = uiaxes(fig,'XDir',“反向”); x = linspace(-pi,pi); y = sin(x); plot(ax,x,y)

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

斧子。YDir =“反向”;

Specify the UI axes position by setting thePositionproperty. 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]);

Create a surface plot in UI axes. Enable zooming using thezoomfunction. Then click the surface to zoom in. For UI axes,zoomonly supports theon,off, and zoom factor arguments.

ax = uiaxes; s = surf(ax,peaks); zoom(ax,'on')

Similarly, you can rotate the surface or enable panning using therotate3dorpanfunction, respectively. For UI axes, bothrotate3dandpanonly support theonandoffarguments.

Input Arguments

collapse all

UI axes parent container, specified as aFigurecreated using theuifigurefunction, or one of its child containers:Tab,Panel, orButtonGroup.

Name-Value Pair Arguments

Specify optional comma-separated pairs ofName,Valuearguments.Nameis the argument name andValueis the corresponding value.Namemust appear inside single quotes (' '). You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN.

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

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

collapse all

Minimum and maximum limits, specified as a two-element vector of the form[min max], wheremaxis greater thanmin. 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-inforinf, respectively.

Example:斧子。XLim = 10 [0]

Example:斧子。YLim = [-inf 10]

Example:斧子。ZLim = [0 inf]

Alternatively, use thexlim,ylim, andzlimfunctions to set the limits. For an example, seeSpecify Axis Limits.

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

Axis scale, specified as one of these values.

Value Description Result
'linear'

Linear scale

Example:斧子。XScale = 'linear'

'log'

Log scale

Example:斧子。XScale = 'log'

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

Line Style Description Resulting Line
“- - -” Solid line

'--' Dashed line

':' Dotted line

'-.' Dash-dotted line

'none' No line No line

To display the grid lines, use thegrid oncommand or set theXGrid,YGrid, orZGridproperty to'on'.

Example:斧子。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. Theleftandbottomelements define the position of the rectangle, measured from the lower left corner to the lower left corner of the parent container. Thewidthandheightdefine the size of the rectangle. The values are measured in units determined by theUnitsproperty. By default, the units are pixels.

Output Arguments

collapse all

UIAxesobject. Useaxto set properties of theUIAxesafter they are created.

Limitations

  • 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

Functions

Properties

Introduced in R2016a

Was this topic helpful?