From 1aabaafb1573ca4d92756cc873b6c3b76f674954 Mon Sep 17 00:00:00 2001 From: Mahdieh Ebrahimi Date: Fri, 6 Dec 2024 12:54:36 +0100 Subject: [PATCH 1/2] Update plot.py --- amep/plot.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/amep/plot.py b/amep/plot.py index 5f170f7..66d6e5f 100644 --- a/amep/plot.py +++ b/amep/plot.py @@ -914,6 +914,8 @@ def box(axis: mpl.axes.Axes, box_boundary: np.ndarray, **kwargs) -> None: ------- None. ''' + warnings.simplefilter('always', PendingDeprecationWarning) + 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 @@ -929,6 +931,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, From 4822faf299aff067d648128c5d48a41a857b321b Mon Sep 17 00:00:00 2001 From: Mahdieh Ebrahimi Date: Thu, 19 Dec 2024 10:33:58 +0100 Subject: [PATCH 2/2] Update plot.py --- amep/plot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/amep/plot.py b/amep/plot.py index 66d6e5f..0ce76d8 100644 --- a/amep/plot.py +++ b/amep/plot.py @@ -914,7 +914,6 @@ def box(axis: mpl.axes.Axes, box_boundary: np.ndarray, **kwargs) -> None: ------- None. ''' - warnings.simplefilter('always', PendingDeprecationWarning) 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: