8000 Update plot.py by MahdiehEbrahimii · Pull Request #91 · amepproject/amep · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update plot.py #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions amep/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ def box(axis: mpl.axes.Axes, box_boundary: np.ndarray, **kwargs) -> None:
-------
None.
'''
warnings.warn("The function 'plot.box' will be removed in version 2.0.0. Please use the function 'plot.box_boundary' instead.", PendingDeprecationWarning)
defaultKwargs = {'c': 'k', 'ls': '-', 'marker': ''}
if 'color' in kwargs:
# either 'c' or 'color' can be given, not both
Expand All @@ -929,6 +930,40 @@ def box(axis: mpl.axes.Axes, box_boundary: np.ndarray, **kwargs) -> None:
axis.plot(box_boundary[0], [box_boundary[1,1],box_boundary[1,1]], **kwargs)


def box_boundary(axis: mpl.axes.Axes, box_boundary: np.ndarray, **kwargs) -> None:
r'''
Adds the simulation box to the given axis.

Parameters
----------
axis : AxisSubplot
Matplotlib.pyplot AxisSubplot object.
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]])`.
**kwargs :
Forwarded to axis.plot.

Returns
-------
None.
'''
defaultKwargs = {'c': 'k', 'ls': '-', 'marker': ''}
if 'color' in kwargs:
# either 'c' or 'color' can be given, not both
kwargs['c'] = kwargs['color']
del kwargs['color']
if 'linestyle' in kwargs:
kwargs['ls'] = kwargs['linestyle']
del kwargs['linestyle']
kwargs = defaultKwargs | kwargs
axis.plot([box_boundary[0,0],box_boundary[0,0]], box_boundary[1], **kwargs)
axis.plot([box_boundary[0,1],box_boundary[0,1]], box_boundary[1], **kwargs)
axis.plot(box_boundary[0], [box_boundary[1,0],box_boundary[1,0]], **kwargs)
axis.plot(box_boundary[0], [box_boundary[1,1],box_boundary[1,1]], **kwargs)



def particles(
ax: mpl.axes.Axes, coords: np.ndarray, box_boundary: np.ndarray,
radius: np.ndarray | float, scalefactor: float = 1.0,
Expand Down
Loading
2A29
0