Python中的 Matplotlib.axes.Axes.barbs()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Axes 类包含大部分图形元素:Axis、Tick、Line2D、Text、Polygon 等,并设置坐标系。 Axes 的实例通过回调属性支持回调。
matplotlib.axes.Axes.barbs()函数
matplotlib 库的 axes 模块中的Axes.barbs()函数也用于绘制倒钩的 2D 字段。
Syntax: Axes.barbs(self, *args, data=None, **kw)
Parameters: This method accept the following parameters that are described below:
- X, Y : These parameter are the x and y coordinates of the barb locations.
- U, V: These parameter are the x and y components of the barb shaft.
- C : This parameter contains the numeric data that defines the barb colors by colormapping via norm and cmap.
- length : This parameter is the length of the barb in points.
- pivot : This parameter is the part of the arrow that is anchored to the X, Y grid.
- barbcolor : This parameter is analogous to the edgecolor parameter for polygons, which can be used instead.
- flagcolor : This parameter is analogous to the facecolor parameter for polygons.
- sizes : This parameter is the dictionary of coefficients specifying the ratio of a given feature to the length of the barb.
- fill_empty : This parameter is used to fill the empty barbs with the flag color.
- barb_increments : This parameter is the dictionary of increments specifying values to associate with different parts of the barb.
- flip_barb : This parameter is the single value is applied to all barbs.
Returns: This method returns the the following:
- barbs : This return the Barbs.
注意:此函数适用于 Matplotlib 版本 >= 3.1
下面的示例说明了 matplotlib.axes 中的 matplotlib.axes.Axes.barbs()函数:
示例 1:
# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 15, 5)
fig1, axs1 = plt.subplots()
axs1.barbs(x**3, x**3, x * 2, x * 2, x * 3,
fill_empty = True)
axs1.set_title('matplotlib.axes.Axes.barbs()\
Example', fontsize = 14, fontweight ='bold')
plt.show()
输出:
示例 2:
# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 15, 5)
X, Y = np.meshgrid(x, x)
U, V = X**2, Y**2
fig1, axs1 = plt.subplots()
axs1.barbs(X, Y, U, V, U * 2, fill_empty = True)
axs1.set_title('matplotlib.axes.Axes.barbs()\
Example', fontsize = 14, fontweight ='bold')
plt.show()
输出: