Create UI axes for plots in apps
collapse all in page
Syntax
Description
example
ax = uiaxes
creates a UI axes in a new figure window and returns the UIAxes
object. MATLAB® calls the uifigure function to create the figure.
UIAxes
objects are useful for creating Cartesian plots in apps. They are very similar to the Cartesian Axes
objects returned by the axes
function. Thus, you can pass a UIAxes
object to most functions that accept an Axes
object. For more information, see Differences Between UIAxes and Axes Objects.
example
ax = uiaxes(Name,Value)
specifies UIAxes
property values using one or more Name,Value
pair arguments.
example
ax = uiaxes(parent)
creates the UI axes in the specified parent container. The parent can be a Figure
created using the uifigure function, or one of its child containers.
ax = uiaxes(parent,Name,Value)
specifies UIAxes
property values using one or more Name,Value
arguments.
Examples
collapse all
Create Plots in UI Axes
Create a line plot and a scatter plot in UI axes.
Create a 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);plot(ax,x,y)
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.
hold(ax,'on')y2 = 5*sin(x) + randn(1,50);scatter(ax,x,y2)
Specify UI Axes Properties
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);plot(ax,x,y)
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 UI Axes Position
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 Panel
Add UI axes to a panel within a 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
parent
— Parent container
Figure
object | Panel
object | Tab
object | GridLayout
object | TiledChartLayout
object
Parent container, specified as a Figure
, Panel
, Tab
, GridLayout
, or TiledChartLayout
object. If no container is specified, MATLAB calls the uifigure
function to create a new Figure
object that serves as the parent container.
Name-Value Arguments
Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN
, where Name
is the argument name and Value
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose Name
in quotes.
Example: 'Xscale','linear','YScale','log'
The properties list here are only a subset. For a full list, see UIAxes Properties.
Output Arguments
collapse all
ax
— UIAxes
object
UIAxes
object
UIAxes
object. Use ax
to set properties of the UIAxes
after they are created.
More About
collapse all
Differences Between UIAxes
and Axes
Objects
This table describes the properties that are different for UIAxes
and Axes
objects. For more information on creating charts in apps, see Display Graphics in App Designer.
Property | UIAxes Objects | Axes Objects |
---|---|---|
NextPlot | The default value is Note that passing a | The default value is |
Position | The default The | The default The |
Units | The default value is | The default value is |
FontUnits | The default value is | The default value is |
Version History
Introduced in R2016a
See Also
Functions
- uifigure
Properties
- UIAxes Properties
Tools
- App Designer
Topics
- Display Graphics in App Designer
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本 (日本語)
- 한국 (한국어)
Contact your local office