amep.plot.particles#

amep.plot.particles(ax: Axes, coords: ndarray, box_boundary: ndarray, radius: ndarray | float, scalefactor: float = 1.0, values: ndarray | None = None, cmap: list | str = 'viridis', set_ax_limits: bool = True, vmin: float | None = None, vmax: float | None = None, cscale: str = 'lin', verbose: bool = False, **kwargs) None#

Visualize particles as circles on a matplotlib axes object.

It works only in 2D and considers x and y coordinates for the plot.

Notes

The particles are only visualized in their proper size (radius) if linewidth=0. In case you want to color the edge of the particles, set linewidth to a non-zero float and pass edgecolor with your desired color for the edge of the particles. This will cause the particles to overlap more than they are supposed to. Therefore, you might consider counter-acting this by choosing a suitable value for scalefactor.

Parameters:
  • ax (AxisSubplot) – The matplotlib axes object where the particles will be plotted.

  • coords (np.ndarray) – An array of coordinates for the particles.

  • box_boundary (np.ndarray of shape (3,2)) – Boundary of the simulation box in the form of np.array([[xmin, xmax], [ymin, ymax], [zmin, zmax]]).

  • radius (float or np.ndarray) – The radius of the particles.

  • scalefactor (float, optional) – Scales the size of the particles by this factor. The default is 1.0.

  • values (np.ndarray or None, optional) – Values used to color the particles. The default is None.

  • cmap (list or str, optional) – A list representing the colormap to use for the particles or the name of a matplotlib colormap. The default is ‘viridis’.

  • set_ax_limits (bool, optional) – If True axis limits are set to box size. Set to False if combined with inset functions! The default is True.

  • vmin (float or None, optional) – Lower limit for coloring the particles. The default is None.

  • vmax (float or None, optional) – Upper limit for coloring the particles. The default is None.

  • cscale (str, optional) – Color scale. Use ‘lin’ for a linear scale and ‘log’ for a logarithmic scale. The default is ‘lin’.

  • verbose (bool, optional) – If True, runtime information is printed. The default is False.

  • **kwargs – Keyword arguments are forwarded to matplotlib.collections.PatchCollection.

Return type:

mpl.collections.PatchCollection

Examples

>>> import amep
>>> traj = amep.load.traj("../examples/data/lammps.h5amep")
>>> frame = traj[-1]
>>> fig, axs = amep.plot.new(figsize=(3, 3))
>>> amep.plot.particles(
...     axs, frame.coords(), frame.box, frame.radius()
... )
>>> axs.set_xlabel(r"$x$")
>>> axs.set_ylabel(r"$y$")
>>> fig.savefig("./figures/plot/plot-particles.png")
>>>
../_images/plot-particles.png