📜  Python中的 Matplotlib.axes.Axes.triplot()

📅  最后修改于: 2022-05-13 01:54:48.605000             🧑  作者: Mango

Python中的 Matplotlib.axes.Axes.triplot()

Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Axes 类包含大部分图形元素:Axis、Tick、Line2D、Text、Polygon 等,并设置坐标系。 Axes 的实例通过回调属性支持回调。

matplotlib.axes.Axes.triplot()函数

matplotlib 库的 axes 模块中的Axes.triplot()函数也用于创建非结构化三角形网格作为线和/或标记。

下面的示例说明了 matplotlib.axes 中的 matplotlib.axes.Axes.triplot()函数:

示例 1:

Axes.triplot(ax, *args, **kwargs)

输出:

示例 2:

# Implementation of matplotlib function
import matplotlib.pyplot as plt
import matplotlib.tri as mtri
import numpy as np
    
# Create triangulation.
x = np.asarray([0, 1, 2, 3, 0.5, 1.5, 2.5, 1, 2, 1.5])
y = np.asarray([0, 0, 0, 0, 1.0, 1.0, 1.0, 2, 2, 3.0])
triangles = [[0, 1, 4], [1, 5, 4], [2, 6, 5], [4, 5, 7],
             [5, 6, 8], [5, 8, 7], [7, 8, 9], [1, 2, 5],
             [2, 3, 6]]
  
triang = mtri.Triangulation(x, y, triangles)
z = np.cos(1.5 * x) * np.cos(1.5 * y)
    
fig, axs = plt.subplots()
axs.tricontourf(triang, z)
axs.triplot(triang, 'go-', color ='white')
fig.tight_layout()
    
axs.set_title('matplotlib.axes.Axes.triplot() Example')
plt.show()

输出: