Main Content

polar

(不推荐)极坐标图

不推荐使用 polar。请改用 polarplot。有关更新代码的信息,请参阅版本历史记录

说明

polar(theta,rho) 在极坐标中绘制线条,由 theta 表示弧度角,rho 表示每个点的半径值。thetarho 必须大小相同。

示例

polar(theta,rho,LineSpec) 指定极坐标图中所绘制线条的线型、标记符号和颜色。

polar(ax,___) 在指定坐标区而不是当前坐标区 (gca) 中绘图。

ln = polar(___) 返回用于创建极坐标图的 Line 对象。创建极坐标图后,使用 ln 修改极坐标图。有关属性列表,请参阅 Line 属性

示例

全部折叠

使用红色虚线创建一个极坐标图。

theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
polar(theta,rho,"--r")

输入参数

全部折叠

角度值,指定为向量或矩阵。指定弧度值。

半径值,指定为向量或矩阵。

rho 值通过原点形成中心对称反射,旋转 pi 角度(因为 (theta,rho) 可转换为 (rho*cos(theta),rho*sin(theta)))。如果希望获得不同的行为,可以在绘图前操作 rho。例如,您可以将 rho 设置为等于 max(0,rho)abs(rho)

线型、标记和颜色,指定为包含符号的字符串标量或字符向量。符号可以按任意顺序显示。您不需要同时指定所有三个特征(线型、标记和颜色)。例如,如果忽略线型,只指定标记,则绘图只显示标记,不显示线条。

示例: "--or" 是带有圆形标记的红色虚线。

线型描述表示的线条
"-"实线

Sample of solid line

"--"虚线

Sample of dashed line

":"点线

Sample of dotted line

"-."点划线

Sample of dash-dotted line, with alternating dashes and dots

标记描述生成的标记
"o"圆圈

Sample of circle marker

"+"加号

Sample of plus sign marker

"*"星号

Sample of asterisk marker

"."

Sample of point marker

"x"叉号

Sample of cross marker

"_"水平线条

Sample of horizontal line marker

"|"垂直线条

Sample of vertical line marker

"square"方形

Sample of square marker

"diamond"菱形

Sample of diamond marker

"^"上三角

Sample of upward-pointing triangle marker

"v"下三角

Sample of downward-pointing triangle marker

">"右三角

Sample of right-pointing triangle marker

"<"左三角

Sample of left-pointing triangle marker

"pentagram"五角形

Sample of pentagram marker

"hexagram"六角形

Sample of hexagram marker

颜色名称短名称RGB 三元组外观
"red""r"[1 0 0]

Sample of the color red

"green""g"[0 1 0]

Sample of the color green

"blue""b"[0 0 1]

Sample of the color blue

"cyan" "c"[0 1 1]

Sample of the color cyan

"magenta""m"[1 0 1]

Sample of the color magenta

"yellow""y"[1 1 0]

Sample of the color yellow

"black""k"[0 0 0]

Sample of the color black

"white""w"[1 1 1]

Sample of the color white

目标坐标区,指定为 Axes 对象。如果未指定坐标区,则 MATLAB® 将在当前坐标区中进行绘制;或如果不存在 Axes 对象,则创建一个对象。polar 不支持在 PolarAxes 对象中绘图。

扩展功能

版本历史记录

在 R2006a 之前推出

全部折叠

R2016a: 不推荐

不推荐使用 polar。请改用 polarplot。目前没有删除 polar 的计划。

polarplot 函数在一个 PolarAxes 对象中绘制一个或多个图线条,该对象比在 polar 中使用的 Axes 对象具有更多相关的自定义选项。例如,您可以通过设置 PolarAxes 对象的 ThetaAxisUnits 属性来更改极坐标图的单位。

下表显示了 polar 的一些典型用法,以及如何更新代码以改用 polarplot

Objective不推荐推荐差异
在同一坐标区上绘制多个线条。
figure
hold on
polar(theta1,rho1)
...
polar(thetaN,rhoN)
polarplot(theta1,rho1,...,thetaN,rhoN)
  • polar 只接受一对 thetarho 输入。

  • polarplot 接受一对或多对 thetarho 输入。

指定绘图外观。
polar(theta,rho,LineSpec)
polarplot(theta,rho,LineSpec)

polarplot(theta,rho,Name,Value)
  • polar 接受 LineSpec 输入参量以设置所绘制线条的线型、标记符号和颜色。

  • polarplot 接受 LineSpec 输入参量以设置所绘制线条的线型、标记符号和颜色,或接受名称-值参量以设置所绘制线条的任何属性。有关属性列表,请参阅 Line 属性

指定目标坐标区。
polar(ax,__)
polarplot(pax,__)
  • polar 接受一个 Axes 目标坐标区。

  • polarplot 接受一个 PolarAxes 目标坐标区。

另请参阅

| |