@_held_figure<EOL>def voronoi_plot_2d(vor, ax=None):
if vor.points.shape[<NUM_LIT:1>] != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>ax.plot(vor.points[:,<NUM_LIT:0>], vor.points[:,<NUM_LIT:1>], '<STR_LIT:.>')<EOL>ax.plot(vor.vertices[:,<NUM_LIT:0>], vor.vertices[:,<NUM_LIT:1>], '<STR_LIT:o>')<EOL>for simplex in vor.ridge_vertices:<EOL><INDENT>simplex = np.asarray(simplex)<EOL>if np.all(simplex >= <NUM_LIT:0>):<EOL><INDENT>ax.plot(vor.vertices[simplex,<NUM_LIT:0>], vor.vertices[simplex,<NUM_LIT:1>], '<STR_LIT>')<EOL><DEDENT><DEDENT>ptp_bound = vor.points.ptp(axis=<NUM_LIT:0>)<EOL>center = vor.points.mean(axis=<NUM_LIT:0>)<EOL>for pointidx, simplex in zip(vor.ridge_points, vor.ridge_vertices):<EOL><INDENT>simplex = np.asarray(simplex)<EOL>if np.any(simplex < <NUM_LIT:0>):<EOL><INDENT>i = simplex[simplex >= <NUM_LIT:0>][<NUM_LIT:0>]  <EOL>t = vor.points[pointidx[<NUM_LIT:1>]] - vor.points[pointidx[<NUM_LIT:0>]]  <EOL>t /= np.linalg.norm(t)<EOL>n = np.array([-t[<NUM_LIT:1>], t[<NUM_LIT:0>]])  <EOL>midpoint = vor.points[pointidx].mean(axis=<NUM_LIT:0>)<EOL>direction = np.sign(np.dot(midpoint - center, n)) * n<EOL>far_point = vor.vertices[i] + direction * ptp_bound.max()<EOL>ax.plot([vor.vertices[i,<NUM_LIT:0>], far_point[<NUM_LIT:0>]],<EOL>[vor.vertices[i,<NUM_LIT:1>], far_point[<NUM_LIT:1>]], '<STR_LIT>')<EOL><DEDENT><DEDENT>_adjust_bounds(ax, vor.points)<EOL>return ax.figure<EOL>
Plot the given Voronoi diagram in 2-D

Parameters
----------
vor : scipy.spatial.Voronoi instance
    Diagram to plot
ax : matplotlib.axes.Axes instance, optional
    Axes to plot on

Returns
-------
fig : matplotlib.figure.Figure instance
    Figure for the plot

See Also
--------
Voronoi

Notes
-----
Requires Matplotlib.