matplotlib.quiver.Quiver

class matplotlib.quiver.Quiver(ax, *args, scale=None, headwidth=3, headlength=5, headaxislength=4.5, minshaft=1, minlength=1, units='width', scale_units=None, angles='uv', width=None, color='k', pivot='tail', **kw)[源代码]

基类:matplotlib.collections.PolyCollection

箭头的专用多集合。

唯一的API方法是set_vc(),它可以用来更改箭头的大小、方向和颜色;当类实例化时,它们的位置是固定的。这个方法可能在动画中有用。

这个类中的大部分工作都是在draw()方法中完成的,这样就可以获得尽可能多的关于绘图的信息。在随后的draw()调用中,重新计算仅限于可能已更改的内容,因此将计算放入draw()方法中不会造成性能损失。

绘制二维箭头字段。

呼叫签名:

quiver([X, Y], U, V, [C], **kw)

XY 定义箭头位置, UV 定义箭头方向,以及 C 可以选择设置颜色。

箭头的大小

默认设置会自动将箭头的长度调整为合理的大小。要更改此行为,请参见 规模scale_units 参数。

箭头形状

默认值给出一个稍微向后扫掠的箭头;要使头部成为三角形,请使 头轴长度 一样 头长 . 要使箭头更尖,请减少 头宽 或增加 头长头轴长度 . 要使头部相对于轴更小,请缩小所有头部参数。你最好别管明沙夫了。

箭头轮廓

线宽度绿色染料 可用于自定义箭头轮廓。

参数:
X, Y一维或二维阵列,可选

箭头位置的x和y坐标。

如果没有给出,它们将根据 UV .

如果 XY 是1D但是 UV 是二维的, XY 使用 X, Y = np.meshgrid(X, Y) . 在这种情况下 len(X)len(Y) 必须匹配的列和行维度 UV .

U, V一维或二维阵列

箭头向量的x和y方向分量。

它们必须具有相同数量的元素,与箭头位置的数量相匹配。 UV 可能是蒙面的。仅在未遮罩的位置 UVC 将被抽取。

C一维或二维阵列,可选

通过colormapping定义箭头颜色的数值数据 normcmap .

这不支持显式颜色。如果要直接设置颜色,请使用 颜色 相反。大小 C 必须匹配箭头位置的数量。

units{'width'、'height'、'dots'、'inches'、'x'、'y''xy'},默认值:'width'

箭头尺寸(除了 长度 )以该单位的倍数计量。

支持以下值:

  • “宽度”、“高度”:轴的宽度或高度。
  • “点”、“英寸”:基于图形dpi的像素或英寸。
  • “x”、“y”、“xy”: XY\(\sqrt{{X^2 + Y^2}}\) 以数据单位表示。

箭头的比例因单位而异。对于“x”或“y”,箭头随着一个放大而变大;对于其他单位,箭头大小与缩放状态无关。对于“宽度”或“高度”,调整窗口大小时,箭头大小分别随轴的宽度和高度增加;对于“点”或“英寸”,调整大小不会更改箭头。

angles{uv',xy}或类似数组的,默认值:“uv”

确定箭头角度的方法。

  • “uv”:箭头轴纵横比为1,因此如果 U = V 绘图上箭头的方向与水平轴(从正到右)逆时针45度。

    如果箭头表示不基于的数量,请使用此选项 XY 数据坐标。

  • “xy”:箭头从(x,y)指向(x+u,y+v)。例如,在绘制渐变场时使用此选项。

  • 或者,可以将任意角度明确指定为从水平轴逆时针方向以度数为单位的数组。

    In this case U, V is only used to determine the length of the arrows.

注意:反转数据轴将相应地反转箭头,只使用 angles='xy' .

scale可选浮动

每个箭头长度单位的数据单位数,例如每个绘图宽度的m/s;较小的比例参数使箭头更长。默认是 None .

如果 None 根据平均向量长度和向量数目,采用了一种简单的自动缩放算法。箭头长度单位由 scale_units 参数。

scale_units{'width'、'height'、'dots'、'inches'、'x'、'y'、'xy'},可选

如果 规模 克瓦格群岛 None ,箭头长度单位。默认是 None .

例如 scale_units 是英寸, 规模 是2, (u, v) = (1, 0) ,那么向量将是0.5英寸长。

如果 scale_units 是'width'或'height',则矢量为轴宽/高的一半。

如果 scale_units 为“x”,则矢量为0.5 x轴单位。若要在x-y平面中绘制向量,且u和v的单位与x和y相同,请使用 angles='xy', scale_units='xy', scale=1 .

width可选浮动

以箭头单位表示的轴宽度;默认值取决于单位、上方和向量数目的选择;典型的起始值约为绘图宽度的0.005倍。

headwidth浮动,默认值:3

头部宽度为轴宽度的倍数。

headlength浮动,默认值:5

头部长度为轴宽度的倍数。

headaxislength浮动,默认值:4.5

竖井交叉处的头部长度。

minshaft浮点,默认值:1

箭头刻度以下的长度,以头部长度为单位。不要将此设置为小于1,否则小箭头将看起来很糟糕!

minlength浮点,默认值:1

最小长度是轴宽度的倍数;如果箭头长度小于此值,则绘制此直径的点(六边形)。

pivot{'tail','mid','middle','tip'},默认值:'tail'

锚定到的箭头部分 XY 网格。箭头围绕该点旋转。

“mid”是“middle”的同义词。

color颜色或颜色顺序,可选

箭头的显式颜色。如果 C 已经被设定, 颜色 没有效果。

This is a synonym for the PolyCollection facecolor parameter.

其他参数:
**kwargsPolyCollection 属性,可选多集合属性,可选

所有其他关键字参数都传递给 PolyCollection

财产 描述
agg_filter 一种过滤函数,它接受一个(m,n,3)浮点数组和一个dpi值,并返回一个(m,n,3)数组。
alpha 浮动或无
animated 布尔
antialiased 或者aa或者抗锯齿药 布尔或布尔列表
array 恩达雷
capstyle “对接”、“圆形”、“突出”
clim (V最小:浮动,V最大:浮动)
clip_box Bbox
clip_on 布尔
clip_path 面片或(路径、变换)或无
cmap Colormap 或str或None
color rgba元组的颜色或列表
contains 未知的
edgecolor 或ec或edgecolors 颜色或颜色列表或“面”
facecolor 或者facecolors或者fc 颜色或颜色列表
figure Figure
gid STR
hatch '/'、''、''、'-'、'+'、'X'、'O'、'O'、'、'、'*'
in_layout 布尔
joinstyle 'miter'、'round'、'bevel'
label 对象
linestyle 或虚线或线型或ls str或tuple或其列表
linewidth 或线宽或lw 浮动或浮动列表
norm Normalize 或无
offset_position 未知的
offsets 类似于(N,2)或(2,)
path_effects AbstractPathEffect
picker 无、布尔或可呼叫
pickradius 未知的
rasterized 布尔或无
sketch_params (比例:浮动,长度:浮动,随机性:浮动)
snap 布尔或无
transform Transform
url STR
urls str或None列表
visible 布尔
zorder 浮动

参见

Axes.quiverkey
在震动图中添加一个键。
__init__(ax, *args, scale=None, headwidth=3, headlength=5, headaxislength=4.5, minshaft=1, minlength=1, units='width', scale_units=None, angles='uv', width=None, color='k', pivot='tail', **kw)[源代码]
构造函数接受一个必需的参数,一个Axes实例,后跟以下pyplot接口文档中描述的args和kwargs:

绘制二维箭头字段。

呼叫签名:

quiver([X, Y], U, V, [C], **kw)

XY 定义箭头位置, UV 定义箭头方向,以及 C 可以选择设置颜色。

箭头的大小

默认设置会自动将箭头的长度调整为合理的大小。要更改此行为,请参见 规模scale_units 参数。

箭头形状

默认值给出一个稍微向后扫掠的箭头;要使头部成为三角形,请使 头轴长度 一样 头长 . 要使箭头更尖,请减少 头宽 或增加 头长头轴长度 . 要使头部相对于轴更小,请缩小所有头部参数。你最好别管明沙夫了。

箭头轮廓

线宽度绿色染料 可用于自定义箭头轮廓。

参数:
X, Y一维或二维阵列,可选

箭头位置的x和y坐标。

如果没有给出,它们将根据 UV .

如果 XY 是1D但是 UV 是二维的, XY 使用 X, Y = np.meshgrid(X, Y) . 在这种情况下 len(X)len(Y) 必须匹配的列和行维度 UV .

U, V一维或二维阵列

箭头向量的x和y方向分量。

它们必须具有相同数量的元素,与箭头位置的数量相匹配。 UV 可能是蒙面的。仅在未遮罩的位置 UVC 将被抽取。

C一维或二维阵列,可选

通过colormapping定义箭头颜色的数值数据 normcmap .

这不支持显式颜色。如果要直接设置颜色,请使用 颜色 相反。大小 C 必须匹配箭头位置的数量。

units{'width'、'height'、'dots'、'inches'、'x'、'y''xy'},默认值:'width'

箭头尺寸(除了 长度 )以该单位的倍数计量。

支持以下值:

  • “宽度”、“高度”:轴的宽度或高度。
  • “点”、“英寸”:基于图形dpi的像素或英寸。
  • “x”、“y”、“xy”: XY\(\sqrt{{X^2 + Y^2}}\) 以数据单位表示。

箭头的比例因单位而异。对于“x”或“y”,箭头随着一个放大而变大;对于其他单位,箭头大小与缩放状态无关。对于“宽度”或“高度”,调整窗口大小时,箭头大小分别随轴的宽度和高度增加;对于“点”或“英寸”,调整大小不会更改箭头。

angles{uv',xy}或类似数组的,默认值:“uv”

确定箭头角度的方法。

  • “uv”:箭头轴纵横比为1,因此如果 U = V 绘图上箭头的方向与水平轴(从正到右)逆时针45度。

    如果箭头表示不基于的数量,请使用此选项 XY 数据坐标。

  • “xy”:箭头从(x,y)指向(x+u,y+v)。例如,在绘制渐变场时使用此选项。

  • 或者,可以将任意角度明确指定为从水平轴逆时针方向以度数为单位的数组。

    In this case U, V is only used to determine the length of the arrows.

注意:反转数据轴将相应地反转箭头,只使用 angles='xy' .

scale可选浮动

每个箭头长度单位的数据单位数,例如每个绘图宽度的m/s;较小的比例参数使箭头更长。默认是 None .

如果 None 根据平均向量长度和向量数目,采用了一种简单的自动缩放算法。箭头长度单位由 scale_units 参数。

scale_units{'width'、'height'、'dots'、'inches'、'x'、'y'、'xy'},可选

如果 规模 克瓦格群岛 None ,箭头长度单位。默认是 None .

例如 scale_units 是英寸, 规模 是2, (u, v) = (1, 0) ,那么向量将是0.5英寸长。

如果 scale_units 是'width'或'height',则矢量为轴宽/高的一半。

如果 scale_units 为“x”,则矢量为0.5 x轴单位。若要在x-y平面中绘制向量,且u和v的单位与x和y相同,请使用 angles='xy', scale_units='xy', scale=1 .

width可选浮动

以箭头单位表示的轴宽度;默认值取决于单位、上方和向量数目的选择;典型的起始值约为绘图宽度的0.005倍。

headwidth浮动,默认值:3

头部宽度为轴宽度的倍数。

headlength浮动,默认值:5

头部长度为轴宽度的倍数。

headaxislength浮动,默认值:4.5

竖井交叉处的头部长度。

minshaft浮点,默认值:1

箭头刻度以下的长度,以头部长度为单位。不要将此设置为小于1,否则小箭头将看起来很糟糕!

minlength浮点,默认值:1

最小长度是轴宽度的倍数;如果箭头长度小于此值,则绘制此直径的点(六边形)。

pivot{'tail','mid','middle','tip'},默认值:'tail'

锚定到的箭头部分 XY 网格。箭头围绕该点旋转。

“mid”是“middle”的同义词。

color颜色或颜色顺序,可选

箭头的显式颜色。如果 C 已经被设定, 颜色 没有效果。

This is a synonym for the PolyCollection facecolor parameter.

其他参数:
**kwargsPolyCollection 属性,可选多集合属性,可选

所有其他关键字参数都传递给 PolyCollection

财产 描述
agg_filter 一种过滤函数,它接受一个(m,n,3)浮点数组和一个dpi值,并返回一个(m,n,3)数组。
alpha 浮动或无
animated 布尔
antialiased 或者aa或者抗锯齿药 布尔或布尔列表
array 恩达雷
capstyle “对接”、“圆形”、“突出”
clim (V最小:浮动,V最大:浮动)
clip_box Bbox
clip_on 布尔
clip_path 面片或(路径、变换)或无
cmap Colormap 或str或None
color rgba元组的颜色或列表
contains 未知的
edgecolor 或ec或edgecolors 颜色或颜色列表或“面”
facecolor 或者facecolors或者fc 颜色或颜色列表
figure Figure
gid STR
hatch '/'、''、''、'-'、'+'、'X'、'O'、'O'、'、'、'*'
in_layout 布尔
joinstyle 'miter'、'round'、'bevel'
label 对象
linestyle 或虚线或线型或ls str或tuple或其列表
linewidth 或线宽或lw 浮动或浮动列表
norm Normalize 或无
offset_position 未知的
offsets 类似于(N,2)或(2,)
path_effects AbstractPathEffect
picker 无、布尔或可呼叫
pickradius 未知的
rasterized 布尔或无
sketch_params (比例:浮动,长度:浮动,随机性:浮动)
snap 布尔或无
transform Transform
url STR
urls str或None列表
visible 布尔
zorder 浮动

参见

Axes.quiverkey
在震动图中添加一个键。
__module__ = 'matplotlib.quiver'
ax()[源代码]

[Deprecated]

笔记

3.3 版后已移除:

draw(renderer)[源代码]

使用给定的渲染器绘制艺术家(及其子对象)。

如果艺术家不可见,则此操作无效 (Artist.get_visible 返回False)。

参数:
渲染器RendererBase 子类。RenderBase子类。

笔记

此方法在Artist子类中被重写。

get_datalim(transData)[源代码]
quiver_doc = "\nPlot a 2D field of arrows.\n\nCall signature::\n\n quiver([X, Y], U, V, [C], **kw)\n\n*X*, *Y* define the arrow locations, *U*, *V* define the arrow directions, and\n*C* optionally sets the color.\n\n**Arrow size**\n\nThe default settings auto-scales the length of the arrows to a reasonable size.\nTo change this behavior see the *scale* and *scale_units* parameters.\n\n**Arrow shape**\n\nThe defaults give a slightly swept-back arrow; to make the head a\ntriangle, make *headaxislength* the same as *headlength*. To make the\narrow more pointed, reduce *headwidth* or increase *headlength* and\n*headaxislength*. To make the head smaller relative to the shaft,\nscale down all the head parameters. You will probably do best to leave\nminshaft alone.\n\n**Arrow outline**\n\n*linewidths* and *edgecolors* can be used to customize the arrow\noutlines.\n\nParameters\n----------\nX, Y : 1D or 2D array-like, optional\n The x and y coordinates of the arrow locations.\n\n If not given, they will be generated as a uniform integer meshgrid based\n on the dimensions of *U* and *V*.\n\n If *X* and *Y* are 1D but *U*, *V* are 2D, *X*, *Y* are expanded to 2D\n using ``X, Y = np.meshgrid(X, Y)``. In this case ``len(X)`` and ``len(Y)``\n must match the column and row dimensions of *U* and *V*.\n\nU, V : 1D or 2D array-like\n The x and y direction components of the arrow vectors.\n\n They must have the same number of elements, matching the number of arrow\n locations. *U* and *V* may be masked. Only locations unmasked in\n *U*, *V*, and *C* will be drawn.\n\nC : 1D or 2D array-like, optional\n Numeric data that defines the arrow colors by colormapping via *norm* and\n *cmap*.\n\n This does not support explicit colors. If you want to set colors directly,\n use *color* instead. The size of *C* must match the number of arrow\n locations.\n\nunits : {'width', 'height', 'dots', 'inches', 'x', 'y' 'xy'}, default: 'width'\n The arrow dimensions (except for *length*) are measured in multiples of\n this unit.\n\n The following values are supported:\n\n - 'width', 'height': The width or height of the axis.\n - 'dots', 'inches': Pixels or inches based on the figure dpi.\n - 'x', 'y', 'xy': *X*, *Y* or :math:`\\sqrt{X^2 + Y^2}` in data units.\n\n The arrows scale differently depending on the units. For\n 'x' or 'y', the arrows get larger as one zooms in; for other\n units, the arrow size is independent of the zoom state. For\n 'width or 'height', the arrow size increases with the width and\n height of the axes, respectively, when the window is resized;\n for 'dots' or 'inches', resizing does not change the arrows.\n\nangles : {'uv', 'xy'} or array-like, default: 'uv'\n Method for determining the angle of the arrows.\n\n - 'uv': The arrow axis aspect ratio is 1 so that\n if *U* == *V* the orientation of the arrow on the plot is 45 degrees\n counter-clockwise from the horizontal axis (positive to the right).\n\n Use this if the arrows symbolize a quantity that is not based on\n *X*, *Y* data coordinates.\n\n - 'xy': Arrows point from (x, y) to (x+u, y+v).\n Use this for plotting a gradient field, for example.\n\n - Alternatively, arbitrary angles may be specified explicitly as an array\n of values in degrees, counter-clockwise from the horizontal axis.\n\n In this case *U*, *V* is only used to determine the length of the\n arrows.\n\n Note: inverting a data axis will correspondingly invert the\n arrows only with ``angles='xy'``.\n\nscale : float, optional\n Number of data units per arrow length unit, e.g., m/s per plot width; a\n smaller scale parameter makes the arrow longer. Default is *None*.\n\n If *None*, a simple autoscaling algorithm is used, based on the average\n vector length and the number of vectors. The arrow length unit is given by\n the *scale_units* parameter.\n\nscale_units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, optional\n If the *scale* kwarg is *None*, the arrow length unit. Default is *None*.\n\n e.g. *scale_units* is 'inches', *scale* is 2.0, and ``(u, v) = (1, 0)``,\n then the vector will be 0.5 inches long.\n\n If *scale_units* is 'width' or 'height', then the vector will be half the\n width/height of the axes.\n\n If *scale_units* is 'x' then the vector will be 0.5 x-axis\n units. To plot vectors in the x-y plane, with u and v having\n the same units as x and y, use\n ``angles='xy', scale_units='xy', scale=1``.\n\nwidth : float, optional\n Shaft width in arrow units; default depends on choice of units,\n above, and number of vectors; a typical starting value is about\n 0.005 times the width of the plot.\n\nheadwidth : float, default: 3\n Head width as multiple of shaft width.\n\nheadlength : float, default: 5\n Head length as multiple of shaft width.\n\nheadaxislength : float, default: 4.5\n Head length at shaft intersection.\n\nminshaft : float, default: 1\n Length below which arrow scales, in units of head length. Do not\n set this to less than 1, or small arrows will look terrible!\n\nminlength : float, default: 1\n Minimum length as a multiple of shaft width; if an arrow length\n is less than this, plot a dot (hexagon) of this diameter instead.\n\npivot : {'tail', 'mid', 'middle', 'tip'}, default: 'tail'\n The part of the arrow that is anchored to the *X*, *Y* grid. The arrow\n rotates about this point.\n\n 'mid' is a synonym for 'middle'.\n\ncolor : color or color sequence, optional\n Explicit color(s) for the arrows. If *C* has been set, *color* has no\n effect.\n\n This is a synonym for the `~.PolyCollection` *facecolor* parameter.\n\nOther Parameters\n----------------\n**kwargs : `~matplotlib.collections.PolyCollection` properties, optional\n All other keyword arguments are passed on to `.PolyCollection`:\n\n \n .. table::\n :class: property-table\n\n ================================================================================================= =====================================================================================================\n Property Description \n ================================================================================================= =====================================================================================================\n :meth:`agg_filter <matplotlib.artist.Artist.set_agg_filter>` a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array\n :meth:`alpha <matplotlib.artist.Artist.set_alpha>` float or None \n :meth:`animated <matplotlib.artist.Artist.set_animated>` bool \n :meth:`antialiased <matplotlib.collections.Collection.set_antialiased>` or aa or antialiaseds bool or list of bools \n :meth:`array <matplotlib.cm.ScalarMappable.set_array>` ndarray \n :meth:`capstyle <matplotlib.collections.Collection.set_capstyle>` {'butt', 'round', 'projecting'} \n :meth:`clim <matplotlib.cm.ScalarMappable.set_clim>` (vmin: float, vmax: float) \n :meth:`clip_box <matplotlib.artist.Artist.set_clip_box>` `.Bbox` \n :meth:`clip_on <matplotlib.artist.Artist.set_clip_on>` bool \n :meth:`clip_path <matplotlib.artist.Artist.set_clip_path>` Patch or (Path, Transform) or None \n :meth:`cmap <matplotlib.cm.ScalarMappable.set_cmap>` `.Colormap` or str or None \n :meth:`color <matplotlib.collections.Collection.set_color>` color or list of rgba tuples \n :meth:`contains <matplotlib.artist.Artist.set_contains>` unknown \n :meth:`edgecolor <matplotlib.collections.Collection.set_edgecolor>` or ec or edgecolors color or list of colors or 'face' \n :meth:`facecolor <matplotlib.collections.Collection.set_facecolor>` or facecolors or fc color or list of colors \n :meth:`figure <matplotlib.artist.Artist.set_figure>` `.Figure` \n :meth:`gid <matplotlib.artist.Artist.set_gid>` str \n :meth:`hatch <matplotlib.collections.Collection.set_hatch>` {'/', '\\\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} \n :meth:`in_layout <matplotlib.artist.Artist.set_in_layout>` bool \n :meth:`joinstyle <matplotlib.collections.Collection.set_joinstyle>` {'miter', 'round', 'bevel'} \n :meth:`label <matplotlib.artist.Artist.set_label>` object \n :meth:`linestyle <matplotlib.collections.Collection.set_linestyle>` or dashes or linestyles or ls str or tuple or list thereof \n :meth:`linewidth <matplotlib.collections.Collection.set_linewidth>` or linewidths or lw float or list of floats \n :meth:`norm <matplotlib.cm.ScalarMappable.set_norm>` `.Normalize` or None \n :meth:`offset_position <matplotlib.collections.Collection.set_offset_position>` unknown \n :meth:`offsets <matplotlib.collections.Collection.set_offsets>` array-like (N, 2) or (2,) \n :meth:`path_effects <matplotlib.artist.Artist.set_path_effects>` `.AbstractPathEffect` \n :meth:`picker <matplotlib.artist.Artist.set_picker>` None or bool or callable \n :meth:`pickradius <matplotlib.collections.Collection.set_pickradius>` unknown \n :meth:`rasterized <matplotlib.artist.Artist.set_rasterized>` bool or None \n :meth:`sketch_params <matplotlib.artist.Artist.set_sketch_params>` (scale: float, length: float, randomness: float) \n :meth:`snap <matplotlib.artist.Artist.set_snap>` bool or None \n :meth:`transform <matplotlib.artist.Artist.set_transform>` `.Transform` \n :meth:`url <matplotlib.artist.Artist.set_url>` str \n :meth:`urls <matplotlib.collections.Collection.set_urls>` list of str or None \n :meth:`visible <matplotlib.artist.Artist.set_visible>` bool \n :meth:`zorder <matplotlib.artist.Artist.set_zorder>` float \n ================================================================================================= =====================================================================================================\n\n\nSee Also\n--------\n.Axes.quiverkey : Add a key to a quiver plot.\n"
remove()[源代码]

如果可能的话,将艺术家从人物中移除。

在重新绘制图形之前,效果将不可见,例如,使用 FigureCanvasBase.draw_idle . 呼叫 relim 如果需要,更新轴限制。

注: relim 即使集合已添加到轴,也不会看到集合 自动着陆系统 =真。

注意:不支持删除艺术家的图例项。

set_UVC(U, V, C=None)[源代码]

使用实例 matplotlib.quiver.Quiver