Main Content

uigauge

创建仪表组件

说明

g = uigauge 在新图窗窗口中创建一个圆形仪表,并返回 Gauge 对象。MATLAB® 调用 uifigure 函数来创建该图窗。

g = uigauge(style) 指定仪表样式。

示例

g = uigauge(parent) 在指定的父容器中创建仪表。父容器可以是使用 uifigure 函数创建的 Figure 或其子容器之一。

示例

g = uigauge(parent,style) 在指定的父容器中创建指定样式的仪表。

示例

g = uigauge(___,Name,Value) 使用一个或多个 Name,Value 对组参数指定对象属性。可将此选项与上述语法中的任何输入参数组合一起使用。

示例

全部折叠

fig = uifigure;
cg = uigauge(fig);

Circular gauge in a UI figure window. The gauge has values from 0 to 100 laid out clockwise in a circle with the needle at 0.

fig = uifigure;
lg  = uigauge(fig,'linear');

Linear gauge in a UI figure window. The gauge has values from 0 to 100 laid out in a horizontal line with the needle at 0.

指定面板作为线性仪表的父容器。

fig = uifigure;
pnl = uipanel(fig);
lg = uigauge(pnl,'linear');

Linear gauge in a panel in a UI figure window. The gauge has values from 0 to 100 laid out in a horizontal line with the needle at 0.

创建圆形仪表并设置 ScaleDirection 属性,指定指针逆时针移动。

fig = uifigure;
cg = uigauge(fig,'ScaleDirection','counterclockwise');

更改主刻度的数量、指定匹配的刻度标签并删除次刻度。

cg.MajorTicks = [0:10:100];
cg.MajorTickLabels = {'0','10','20','30','40','50','60','70','80','90','100'};
cg.MinorTicks = [];

Circular gauge in a UI figure window. The gauge has values from 0 to 100 laid out counterclockwise in a circle with the needle at 0 and labels for every tenth value.

fig = uifigure;
cg = uigauge(fig,'ScaleColors',{'yellow','red'},...
                 'ScaleColorLimits', [60 80; 80 100]);

Circular gauge in a UI figure window. The gauge has values from 0 to 100 laid out clockwise. The values between 60 and 80 are yellow, and the values between 80 and 100 are red.

输入参数

全部折叠

仪表的样式,指定为下列值之一:

样式外观
'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.

父容器,指定为使用 uifigure 函数创建的 Figure 对象或其子容器之一:TabPanelButtonGroupGridLayout。如果不指定父容器,MATLAB 会调用 uifigure 函数创建新 Figure 对象充当父容器。

名称-值参数

将可选的参数对组指定为 Name1=Value1,...,NameN=ValueN,其中 Name 是参数名称,Value 是对应的值。名称-值参数必须出现在其他参数之后,但参数对组的顺序无关紧要。

在 R2021a 之前,使用逗号分隔每个名称和值,并用引号将 Name 引起来。

每种类型的仪表支持一组不同的属性。有关每种类型的属性和描述的完整列表,请参阅相关联的属性页。

版本历史记录

在 R2016a 中推出