主要内容

feather

创建以 x 轴为起点的箭头

  • Arrows along the x-axis

说明

feather(U,V) 绘制以 x 轴为起点的箭头。使用笛卡尔分量 UV 指定箭头方向,其中 U 表示 x 分量,V 表示 y 分量。第 n 个箭头的起始点位于 x 轴上的 n。箭头的数量与 UV 中的元素数相匹配。

示例

feather(Z) 使用 Z 指定的复数值绘制箭头,实部表示 x 分量,虚部表示 y 分量。此语法等效于 feather(real(Z),imag(Z))

示例

feather(___,LineSpec) 设置箭头的线型、标记符号和颜色。

示例

feather(___,Name=Value) 使用一个或多个名称-值参量设置绘图的属性。例如,您可以指定箭头的颜色和粗细。有关属性列表,请参阅 Line 属性 (自 R2024b 起)

feather(ax,___) 在指定坐标区(而不是当前坐标区)中绘制箭头。

示例

f = feather(___) 返回由包含 length(U)+1 个元素的 Line 对象组成的向量。前 length(U) 个元素表示各个箭头,最后一个元素表示沿 x 轴的水平线。创建绘图后,使用这些 Line 对象来控制绘图的外观。

示例

示例

全部折叠

通过将每个箭头的分量指定为笛卡尔值来创建羽状图。第 n 个箭头以 x 轴上的 n 为起点。

t = -pi/2:pi/8:pi/2;
u = 10*sin(t);
v = 10*cos(t);
feather(u,v)

Figure contains an axes object. The axes object contains 10 objects of type line.

通过首先将极坐标转换为笛卡尔坐标,使用极坐标创建羽状图。

要完成此操作,请先用极坐标创建向量。使用 pol2cart 函数将它们转换为笛卡尔坐标。然后,创建绘图。

th = -pi/2:pi/16:0;
r = 10*ones(size(th));
[u,v] = pol2cart(th,r);
feather(u,v)

Figure contains an axes object. The axes object contains 10 objects of type line.

创建一个复数值向量。然后,使用羽状图显示这些复数值。实部确定每个箭头的 x 分量,虚部确定 y 分量。

Z = [2+3i -1-3i -1+i 2i 3-4i -2-2i -2+4i 0.5-i -3i 1+i];
feather(Z)

Figure contains an axes object. The axes object contains 11 objects of type line.

创建一个具有红色箭头的羽状图。

t = -pi/2:pi/8:pi/2;
u = 10*sin(t);
v = 10*cos(t);
feather(u,v,'r')

Figure contains an axes object. The axes object contains 10 objects of type line.

通过为单个箭头赋予变量,然后设置其属性来指定该箭头的线宽和颜色。要完成此操作,请先创建一个羽状图并返回一个 Line 对象数组。

t = -pi/2:pi/8:pi/2;
u = 10*sin(t);
v = 10*cos(t);
f = feather(u,v);

为第一个箭头赋予一个变量。第一个箭头对应于 uv 的第一组元素。然后,更改线宽和颜色。

f1 = f(1);
f1.Color = 'r';
f1.LineWidth = 2;

Figure contains an axes object. The axes object contains 10 objects of type line.

从 R2019b 开始,您可以使用 tiledlayoutnexttile 函数显示分块图。调用 tiledlayout 函数以创建 1×2 分块图布局。调用 nexttile 函数创建一个坐标区对象,并将该对象返回为 ax1。通过将 ax1 传递给 feather 函数来创建左图。通过将坐标区传递给 title 函数为绘图添加标题。重复上述过程以创建右图。

tiledlayout(1,2)

% Left plot
ax1 = nexttile;
t = 0:pi/8:pi/2;
u1 = 10*sin(t);
v1 = 10*cos(t);
feather(ax1,u1,v1)
title(ax1,'Left Plot')

% Right plot
ax2 = nexttile;
u2 = zeros(5,1);
v2 = [1 -2 3 -4 5];
feather(ax2,u2,v2)
title(ax2,'Right Plot')

Figure contains 2 axes objects. Axes object 1 with title Left Plot contains 6 objects of type line. Axes object 2 with title Right Plot contains 6 objects of type line.

输入参数

全部折叠

x 分量,指定为标量、向量或矩阵。指定笛卡尔值。要将数据从极坐标转换为笛卡尔坐标,请使用 pol2cart

U 的大小必须与 V 的大小匹配。

y 分量,指定为标量、向量或矩阵。指定笛卡尔值。要将数据从极坐标转换为笛卡尔坐标,请使用 pol2cart

V 的大小必须与 U 的大小匹配。

复数值,指定为标量、向量或矩阵。Z 的实部表示箭头的 x 分量,虚部表示 y 分量。

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

示例: "--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 对象。

名称-值参数

全部折叠

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

示例: feather([1 2 3 4],[5 6 7 8],LineWidth=2) 绘制一个线条粗细为两磅的箭头。

注意

此处所列的属性只是一部分。有关完整列表,请参阅 Line 属性

线条颜色,指定为 RGB 三元组、十六进制颜色代码、颜色名称或短名称。默认值 [0 0 0] 对应于黑色。

对于自定义颜色,请指定 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"不适用不适用不适用无颜色

下表列出了浅色和深色主题中绘图的默认调色板。

调色板调色板颜色

"gem" - 浅色主题默认值

在 R2025a 之前的版本中: 大多数绘图默认使用这些颜色。

Sample of the "gem" color palette

"glow" - 深色主题默认值

Sample of the "glow" color palette

您可以使用 orderedcolorsrgb2hex 函数获取这些调色板的 RGB 三元组和十六进制颜色代码。例如,获取 "gem" 调色板的 RGB 三元组并将其转换为十六进制颜色代码。

RGB = orderedcolors("gem");
H = rgb2hex(RGB);

在 R2023b 之前的版本中: 使用 RGB = get(groot,"FactoryAxesColorOrder") 获取 RGB 三元组。

在 R2024a 之前的版本中: 使用 H = compose("#%02X%02X%02X",round(RGB*255)) 获取十六进制颜色代码。

示例: "blue"

示例: [0 0 1]

示例: "#0000FF"

线型,指定为下表中列出的选项之一。

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

Sample of solid line

"--"虚线

Sample of dashed line

":"点线

Sample of dotted line

"-."点划线

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

"none"无线条无线条

线宽,指定为以磅为单位的正值,其中 1 磅 = 1/72 英寸。如果该线条具有标记,则线条宽度也会影响标记边。

线宽不能小于像素的宽度。如果将线宽设置为小于系统上像素宽度的值,则线条显示为一个像素的宽度。

扩展功能

全部展开

版本历史记录

在 R2006a 之前推出

全部展开

另请参阅

函数

属性