Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

polaraxes

创建极坐标区

说明

示例

polaraxes 在当前图窗中创建默认的极坐标区。

polaraxes(Name,Value) 使用一个或多个名称-值对组参数指定 PolarAxes 对象的属性(例如 'ThetaDir','clockwise')。有关属性列表,请参阅 PolarAxes 属性

polaraxes(parent,___) 在由 parent 指定的图窗、面板或选项卡中创建极坐标区,而不是在当前图窗中创建。单独使用此选项或与名称-值对组参数一起使用。

pax = polaraxes(___) 返回创建的 PolarAxes 对象。可使用 pax 在创建 PolarAxes 对象后查询和设置其属性。有关属性列表,请参阅 PolarAxes 属性

示例

polaraxes(pax_in) 使 PolarAxes 对象 pax_in 成为当前坐标区。

示例

全部折叠

创建带有极坐标区的新图窗,并将极坐标区对象赋予 pax。向坐标区添加绘图。然后使用 pax 修改坐标区属性。

figure
pax = polaraxes;
theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
polarplot(theta,rho)

pax.ThetaDir = 'clockwise';
pax.FontSize = 12;

Figure contains an axes object with type polaraxes. The polaraxes object contains an object of type line.

在 R2022a 之前,默认情况下极坐标区不包括度符号。要添加度符号,请使用 pax = gca 获取极坐标区。然后使用 pax.ThetaTickLabel = string(pax.ThetaTickLabel) + char(176) 修改刻度标签。

创建带有极坐标区的图窗,并将极坐标区对象赋给 pax。然后,在调用 polarplot 函数之前,确保 pax 是当前坐标区。

figure
pax = polaraxes;

polaraxes(pax)
polarplot(1:10)

Figure contains an axes object with type polaraxes. The polaraxes object contains an object of type line.

输入参数

全部折叠

父容器,指定为 FigurePanelTabTiledChartLayoutGridLayout 对象。

要设置为当前坐标区的极坐标区,指定为 PolarAxes 对象。

名称-值参数

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

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

示例: 'ThetaZeroLocation','top','ThetaDir','clockwise'

此处所列的属性只是一部分。有关完整列表,请参阅 PolarAxes 属性。有些图形函数会在绘图时重置坐标区属性。要避免图形函数覆盖属性值,请在绘图后设置坐标区属性。

角度值的单位,指定为下列值之一:

  • 'degrees' - 以度为单位标记角,并以度为单位解释 ThetaLimThetaTickRAxisLocation 属性值。当您将单位从弧度切换为度时,MATLAB® 将把这三个属性中的弧度值转换为等价的角度值。

  • 'radians' - 以弧度为单位标记角,并以弧度为单位解释 ThetaLimThetaTickRAxisLocation 属性值。当您将单位从度切换为弧度时,MATLAB 将把这三个属性中的角度值转换为等价的弧度值。

示例: ax.ThetaAxisUnits = 'radians';

零参照轴的位置,指定为下表中的值之一。

结果
'right'

Polar axes with zero located on the right. The angles increase as you move counterclockwise around the circle.

'top'

Polar axes with zero pointing up. The angles increase as you move counterclockwise around the circle.

'left'

Polar axes with zero located on the left. The angles increase as you move counterclockwise around the circle.

'bottom'

Polar axes with zero pointing down. The angles increase as you move counterclockwise around the circle.

示例: ax.ThetaZeroLocation = 'left';

角度递减方向,指定为下表中的值之一。

结果
'counterclockwise'

角度按逆时针方向增加。

Polar axes with zero on the right, and the angles increasing as you move counterclockwise around the circle

'clockwise'

角度按顺时针方向增加。

Polar axes with zero on the right, and the angles increasing as you move clockwise around the circle

示例: ax.ThetaDir = 'clockwise';

最小和最大角度值,指定为 [thmin thmax] 形式的二元素向量。如果两个值的差小于 360 度,则 theta 轴为部分圆。

MATLAB 以 ThetaAxisUnits 属性确定的单位来解释值。

示例: ax.ThetaLim = [0 180];

用来显示从原点延伸的线条的角度,指定为递增值向量。MATLAB 用相应的角度值标记线条,除非您使用 ThetaTickLabel 属性指定不同的标签。

MATLAB 以 ThetaAxisUnits 属性确定的单位来解释值。

示例: ax.ThetaTick = [0 90 180 270];

也可以使用 thetaticks 函数指定值。

theta 轴(包括 theta 轴网格线、刻度线、刻度标签)的颜色。将此值指定为 RGB 三元组、十六进制颜色代码、颜色名称或短名称。

注意

如果您指定 GridColor 属性,网格线将改用 GridColor 属性中的颜色。有关详细信息,请参阅 GridColorMode

对于自定义颜色,请指定 RGB 三元组或十六进制颜色代码。

  • RGB 三元组是包含三个元素的行向量,其元素分别指定颜色中红、绿、蓝分量的强度。强度值必须位于 [0,1] 范围内,例如 [0.4 0.6 0.7]

  • 十六进制颜色代码是字符串标量或字符向量,以井号 (#) 开头,后跟三个或六个十六进制数字,范围可以是 0F。这些值不区分大小写。因此,颜色代码 "#FF8800""#ff8800""#F80""#f80" 是等效的。

此外,还可以按名称指定一些常见的颜色。下表列出了命名颜色选项、等效 RGB 三元组和十六进制颜色代码。

颜色名称短名称RGB 三元组十六进制颜色代码外观
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan" "c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"不适用不适用不适用无颜色

以下是 MATLAB 在许多类型的绘图中使用的默认颜色的 RGB 三元组和十六进制颜色代码。

RGB 三元组十六进制颜色代码外观
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

例如,ax.ThetaColor = 'r' 将颜色更改为红色。

Polar axes with red theta-axis tick labels and red theta-axis grid lines. The r-axis tick labels and grid lines are gray.

r 轴的位置,指定为标量角度值。MATLAB 以 ThetaAxisUnits 属性确定的单位解释值。

示例: ax.RAxisLocation = 90;

值沿 r 轴递增的方向,指定为下列值之一:

  • 'normal' - 值从图表中心向外递增。原点处的半径对应于 RLim 属性中存储的最小值(通常为 0)。

  • 'reverse' - 值从图表中心向外递减。原点处的半径对应于 RLim 属性中存储的最大值。

示例: ax.RDir = 'reverse';

最小和最大半径范围,指定为 [rmin rmax] 形式的二元素向量,其中 rmax 是大于 rmin 的数值。您可以指定这两个范围,也可以指定一个范围而让坐标区自动计算另一个范围。

  • 要自动将最小范围设置为最小数据值,请将第一个元素指定为 -inf,例如 [-inf 0]

  • 要自动将最大范围设置为最大数据值,请将第二个元素指定为 inf,例如 [0 inf]

也可以使用 rlim 函数设置这些范围。

示例: ax.RLim = [0 6];

半径刻度值,指定为由递增值组成的向量。半径刻度值是 r 轴上显示圆环线的位置。半径刻度标签是您在每条线旁边看到的标签。使用 RTickLabels 属性指定关联的标签。

示例: ax.RTick = [0 2 4 6];

也可以使用 rticks 函数指定刻度值。

r 轴(包括 r 轴网格线、刻度线和刻度标签)的颜色。将此值指定为 RGB 三元组、十六进制颜色代码、颜色名称或短名称。

注意

如果您指定 GridColor 属性,网格线将改用 GridColor 属性中的颜色。有关详细信息,请参阅 GridColorMode

对于自定义颜色,请指定 RGB 三元组或十六进制颜色代码。

  • RGB 三元组是包含三个元素的行向量,其元素分别指定颜色中红、绿、蓝分量的强度。强度值必须位于 [0,1] 范围内,例如 [0.4 0.6 0.7]

  • 十六进制颜色代码是字符串标量或字符向量,以井号 (#) 开头,后跟三个或六个十六进制数字,范围可以是 0F。这些值不区分大小写。因此,颜色代码 "#FF8800""#ff8800""#F80""#f80" 是等效的。

此外,还可以按名称指定一些常见的颜色。下表列出了命名颜色选项、等效 RGB 三元组和十六进制颜色代码。

颜色名称短名称RGB 三元组十六进制颜色代码外观
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan" "c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"不适用不适用不适用无颜色

以下是 MATLAB 在许多类型的绘图中使用的默认颜色的 RGB 三元组和十六进制颜色代码。

RGB 三元组十六进制颜色代码外观
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

例如,ax.RColor = 'r' 将颜色更改为红色。

Polar axes with red r-axis tick labels and red r-axis grid lines. The theta tick labels and grid lines are gray.

版本历史记录

在 R2016a 中推出

全部展开