amep.plot.field#
- amep.plot.field(ax: <module 'matplotlib.axes' from 'C:\\Users\\Lukas\\anaconda3\\envs\\amep-py-310\\lib\\site-packages\\matplotlib\\axes\\__init__.py'>, density: ~numpy.ndarray, X: ~numpy.ndarray, Y: ~numpy.ndarray, cmap: list | str = 'plasma', box_boundary: ~numpy.ndarray | None = None, vmin: float | None = None, vmax: float | None = None, cscale: str = 'lin', verbose: bool = False, **kwargs) QuadMesh #
Visualize a scalar field on a matplotlib axes object.
It works only in 2D.
- Parameters:
ax (AxisSubplot) – The matplotlib axes object where the field will be plotted.
density (np.ndarray) – An array of scalar values for the field.
X (np.ndarray) – An array of x coordinates for the field.
Y (np.ndarray) – An array of y coordinates for the field.
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’.
box_boundary (np.ndarray | None, optional) – The boundary of the simulation box. Needed if set_ax_limits = True. [[xmin, xmax], [ymin, ymax], [zmin, zmax]]
vmin (float or None, optional) – Lower limit for the colormap. The default is None.
vmax (float or None, optional) – Upper limit for the colormap. 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.pyplot.pcolormesh.
- Return type:
mpl.collections.QuadMesh
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/continuum.h5amep") >>> frame = traj[4] >>> fig, axs = amep.plot.new(figsize=(3.6,3)) >>> mp = amep.plot.field( ... axs, frame.data("c"), *frame.grid ... ) >>> cax = amep.plot.add_colorbar(fig, axs, mp, label=r"$c(x,y)$") >>> axs.set_xlabel(r"$x$") >>> axs.set_ylabel(r"$y$") >>> fig.savefig("./figures/plot/plot-field.png") >>>