8.5. pyafv.visualize_2d
- visualize_2d(pts, diag, r, ax=None, *, selected=None, **kw)[source]
Visualize a 2D snapshot using the diagnostic dictionary diag generated by
pyafv.FiniteVoronoiSimulator.build(). This is basically a wrapper around the vectorized custom plotting functions from the example notebooks and generally preferred over the originalpyafv.FiniteVoronoiSimulator.plot_2d()method. The plotting style followsscipy.spatial.voronoi_plot_2d().Note
If you are visualizing a diag from
ParallelFiniteVoronoiSimulator.build(), you should usevisualize_2d_parallel()instead.- Parameters:
pts (ndarray) – An (N, 2) array of point coordinates.
diag (dict[str, object]) – A diagnostic dict containing Voronoi diagram information.
r (float) – Maximum radius (or denoted as \(\ell\)) used for drawing arcs.
ax (Axes | None) – If provided, draw into the axes; otherwise create a new one.
selected (array-like | None, optional) – Cells to draw. This can be either a one-dimensional array of integer indices or a boolean mask with length equal to
len(pts). If None, draw all cells.cell_colors (color or list, optional) – A single color or a sequence of colors for filling cells, default ‘C2’. Use None for no fill. If selected is provided, full-length per-cell color sequences are sliced to the selected cells.
fill_alpha (float, optional) – Specifies the alpha for cell fills, default 0.1.
fill_zorder (float, optional) – Specifies the z-order for cell fills, default 0.
show_points (bool, optional) – Add cell center points to the plot, default False.
point_size (float, optional) – Specifies the marker area for the points, default 4. If selected is provided, full-length per-cell sequences are sliced to the selected cells.
point_colors (color or list, optional) – A single color or a sequence of colors for the points, default ‘C0’. If selected is provided, full-length per-cell color sequences are sliced to the selected cells.
point_zorder (float, optional) – Specifies the z-order for the points, default 3.
straight_colors (color, optional) – Color for straight contact edges, default ‘C0’.
straight_lw (float, optional) – Line width for straight edges, default 1.0.
straight_alpha (float, optional) – Alpha for straight edges, default 1.0.
straight_capstyle (str, optional) – Cap style for straight edges, default ‘butt’.
straight_zorder (float, optional) – Z-order for straight edges, default 2.
arc_colors (color, optional) – Color for arc non-contact edges, default ‘C2’.
arc_lw (float, optional) – Line width for arc edges, default 1.0.
arc_alpha (float, optional) – Alpha for arc edges, default 1.0.
arc_capstyle (str, optional) – Cap style for arc edges, default ‘butt’.
arc_zorder (float, optional) – Z-order for arc edges, default 1.
auto_adjust_bounds (bool, optional) – Whether to automatically adjust the plot bounds to fit the diagram, default True.
- Returns:
The matplotlib figure object representing the entire canvas.
- Return type: