Python中的 Matplotlib.axes.Axes.fill()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Axes 类包含大部分图形元素:Axis、Tick、Line2D、Text、Polygon 等,并设置坐标系。 Axes 的实例通过回调属性支持回调。
matplotlib.axes.Axes.fill()函数
matplotlib 库的 axes 模块中的Axes.fill()函数用于绘制填充的多边形。
Syntax:
Parameters: This method accept the following parameters that are described below:
- *args: These parameter are the lists of x and y positions of its nodes, optionally followed by a color specifier.
- data: This parameter is an optional parameter and it is an object with labelled data.
Returns: This returns the list of Polygon.
下面的示例说明了 matplotlib.axes 中的 matplotlib.axes.Axes.fill()函数:
示例 1:
Axes.fill(self, *args, data=None, **kwargs)
输出:
示例 2:
# Implementation of matplotlib function
import numpy as np
from matplotlib import patches
import matplotlib.pyplot as plt
x = np.array([1, 4, 1, 4])
y = np.array([1, 1, 4, 4])
fig, ax1 = plt.subplots()
ax1.fill(x, y, facecolor ='green')
ax1.set_title('matplotlib.axes.Axes.fill Example 1')
plt.show()
输出: