scipy.spatial.voronoi_plot_2d#

scipy.spatial.voronoi_plot_2d(vor, ax=None, **kw)[source]#

Plot the given Voronoi diagram in 2-D

Parameters:
vorscipy.spatial.Voronoi instance

Diagram to plot

axmatplotlib.axes.Axes instance, optional

Axes to plot on

show_pointsbool, optional

Add the Voronoi points to the plot.

show_verticesbool, optional

Add the Voronoi vertices to the plot.

line_colorsstring, optional

Specifies the line color for polygon boundaries

line_widthfloat, optional

Specifies the line width for polygon boundaries

line_alphafloat, optional

Specifies the line alpha for polygon boundaries

point_sizefloat, optional

Specifies the size of points

Returns:
figmatplotlib.figure.Figure instance

Figure for the plot

See also

Voronoi

Notes

Requires Matplotlib.

Examples

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.spatial import Voronoi, voronoi_plot_2d

Create a set of points for the example:

>>> rng = np.random.default_rng()
>>> points = rng.random((10,2))

Generate the Voronoi diagram for the points:

>>> vor = Voronoi(points)

Use voronoi_plot_2d to plot the diagram:

>>> fig = voronoi_plot_2d(vor)

Use voronoi_plot_2d to plot the diagram again, with some settings customized:

>>> fig = voronoi_plot_2d(vor, show_vertices=False, line_colors='orange',
...                       line_width=2, line_alpha=0.6, point_size=2)
>>> plt.show()
../../_images/scipy-spatial-voronoi_plot_2d-1_00.png
../../_images/scipy-spatial-voronoi_plot_2d-1_01.png