scipy.spatial.

convex_hull_plot_2d#

scipy.spatial.convex_hull_plot_2d(hull, ax=None)[source]#

在二维空间中绘制给定的凸包图

参数:
hullscipy.spatial.ConvexHull 实例

要绘制的凸包

axmatplotlib.axes.Axes 实例,可选

要绘制的坐标轴

返回值:
figmatplotlib.figure.Figure 实例

图表的图形

参见

ConvexHull

备注

需要 Matplotlib。

示例

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.spatial import ConvexHull, convex_hull_plot_2d

一组随机点的凸包

>>> rng = np.random.default_rng()
>>> points = rng.random((30, 2))
>>> hull = ConvexHull(points)

绘制它

>>> _ = convex_hull_plot_2d(hull)
>>> plt.show()
../../_images/scipy-spatial-convex_hull_plot_2d-1.png