您可以使用
delauney_plot_2d
和
voronoi_plot_2d
辅助函数,只需将Matplotlib轴对象传递给它们。例如。,
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Delaunay, Voronoi, voronoi_plot_2d, delaunay_plot_2d
points = np.array([[0, 0],
[1, 0],
[0.5, 0.5],
[1 , 0.5]])
tri = Delaunay(points)
fig, ax = plt.subplots(figsize=(8, 4))
vor = Voronoi(points)
_ = delaunay_plot_2d(tri, ax=ax)
_ = voronoi_plot_2d(vor, ax=ax)
ax.set_aspect('equal', 'box')
您可以在这些功能中自定义点/线样式等。