Main Content

uigauge

Create gauge component

Description

g = uigauge creates a circular gauge in a new figure and returns the Gauge object. MATLAB® calls the uifigure function to create the figure.

g = uigauge(parent) creates a gauge in the specified parent container. The parent can be a Figure object created using the uifigure function or one of its child containers.

example

g = uigauge(style) creates a gauge of the specified style. The gauge style can be "circular", "linear", "ninetydegree", or "semicircular".

g = uigauge(parent,style) creates a gauge of the specified style in the specified parent container.

example

g = uigauge(___,Name,Value) specifies gauge properties using one or more name-value arguments in addition to any of the input argument combinations in the previous syntaxes. For example, uigauge("Value",10) creates a gauge with a value of 10.

example

Examples

collapse all

Create a circular gauge in a UI figure.

fig = uifigure("Position",[100 100 300 300]);
cg = uigauge(fig);

Figure contains an object of type uigauge.

Create a UI figure with a 2-by-3 grid layout manager. Create four gauges with different styles and specify the grid layout manager as the parent container for each of the gauges. Lay out the linear gauge to span the entire bottom row of the grid.

fig = uifigure("Position",[100 100 470 220]);
g = uigridlayout(fig,[2 3]);
g.RowHeight = {'1x','fit'};
cg = uigauge(g);
ng = uigauge(g,"ninetydegree");
sg = uigauge(g,"semicircular");
lg = uigauge(g,"linear");
lg.Layout.Column = [1 3];

Figure contains an object of type uigridlayout.

Create a circular gauge in a UI figure.

fig = uifigure("Position",[100 100 300 300]);
cg = uigauge(fig);

Figure contains an object of type uigauge.

Specify the gauge limits and value.

cg.Limits = [-50 50];
cg.Value = 20;

Figure contains an object of type uigauge.

Access the values of the major tick marks of the gauge.

mt = cg.MajorTicks
mt = 1×6

   -50   -30   -10    10    30    50

Create a vertical linear gauge in a UI figure.

fig = uifigure("Position",[100 100 300 300]);
lg = uigauge(fig,"linear","Orientation","vertical");

Figure contains an object of type uilineargauge.

Create a ninety-degree gauge in a UI figure.

fig = uifigure("Position",[100 100 300 300]);
ng = uigauge(fig,"ninetydegree");

Figure contains an object of type uininetydegreegauge.

Customize the gauge appearance by changing the number of major ticks, specifying tick labels that correspond to the major ticks, and removing minor ticks.

ng.MajorTicks = 0:50:100;
ng.MajorTickLabels = ["Low","Med","High"];
ng.MinorTicks = [];

Figure contains an object of type uininetydegreegauge.

Create a semicircular gauge in a UI figure.

fig = uifigure("Position",[100 100 300 300]);
sg = uigauge(fig,"semicircular");

Change the colors of the high gauge values by setting the ScaleColors and ScaleColorLimits properties.

sg.ScaleColors = ["yellow","red"];
sg.ScaleColorLimits = [60 80; 80 100];

Figure contains an object of type uisemicirculargauge.

Input Arguments

collapse all

Parent container, specified as a Figure object created using the uifigure function or one of its child containers: Tab, Panel, ButtonGroup, or GridLayout. If you do not specify a parent container, MATLAB calls the uifigure function to create a new Figure object that serves as the parent container.

Style of gauge, specified as one of these values:

StyleAppearance
"circular"Circular gauge. The gauge has values from 0 to 100 laid out clockwise in a circle.
"linear"Linear gauge. The gauge has values from 0 to 100 laid out in a horizontal line.
"ninetydegree"Ninety-degree gauge. The gauge has values from 0 to 100 laid out clockwise in a quarter circle.
"semicircular"Semicircular gauge. The gauge has values from 0 to 100 laid out clockwise in a semicircle.

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.

Example: uigauge(Value=10) specifies the gauge value as 10.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: uigauge("Value",10) specifies the gauge value as 10.

Each style of gauge supports a different set of properties. For a full list of properties and descriptions for each style, see the associated gauge component page.

Version History

Introduced in R2016a