Skip to content

Commit be792c3

Browse files
authored
Figure.grdview: Deprecate parameters contourpen/facadepen/meshpen to contour_pen/facade_pen/mesh_pen (Will be removed in v0.20.0) (#4260)
1 parent 74dedae commit be792c3

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

examples/tutorials/advanced/3d_perspective_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
# %%
7676
# The ``perspective`` azimuth can be changed to set the direction that is "up"
77-
# in the figure. The ``contourpen`` parameter sets the pen used to draw contour
77+
# in the figure. The ``contour_pen`` parameter sets the pen used to draw contour
7878
# lines on the surface. :meth:`pygmt.Figure.colorbar` can be used to add a
7979
# color bar to the figure. The ``cmap`` parameter does not need to be passed
8080
# again. To keep the color bar's alignment similar to the figure, use ``True``
@@ -92,7 +92,7 @@
9292
cmap="geo",
9393
plane="1000+ggrey",
9494
# Set the contour pen thickness to "0.1p"
95-
contourpen="0.1p",
95+
contour_pen="0.1p",
9696
)
9797
fig.colorbar(perspective=True, frame=["a500", "x+lElevation", "y+lm"])
9898
fig.show()

pygmt/src/grdview.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,30 @@
99
from pygmt._typing import PathLike
1010
from pygmt.alias import Alias, AliasSystem
1111
from pygmt.clib import Session
12-
from pygmt.helpers import build_arg_list, fmt_docstring, use_alias
12+
from pygmt.helpers import build_arg_list, deprecate_parameter, fmt_docstring, use_alias
1313

1414
__doctest_skip__ = ["grdview"]
1515

1616

1717
@fmt_docstring
18+
@deprecate_parameter("contourpen", "contour_pen", "v0.18.0", remove_version="v0.20.0")
19+
@deprecate_parameter("facadepen", "facade_pen", "v0.18.0", remove_version="v0.20.0")
20+
@deprecate_parameter("meshpen", "mesh_pen", "v0.18.0", remove_version="v0.20.0")
1821
@use_alias(
1922
C="cmap",
2023
G="drapegrid",
2124
N="plane",
2225
Q="surftype",
23-
Wc="contourpen",
24-
Wm="meshpen",
25-
Wf="facadepen",
2626
I="shading",
2727
f="coltypes",
2828
n="interpolation",
2929
)
3030
def grdview( # noqa: PLR0913
3131
self,
3232
grid: PathLike | xr.DataArray,
33+
contour_pen: str | None = None,
34+
facade_pen: str | None = None,
35+
mesh_pen: str | None = None,
3336
projection: str | None = None,
3437
zscale: float | str | None = None,
3538
zsize: float | str | None = None,
@@ -60,6 +63,9 @@ def grdview( # noqa: PLR0913
6063
- JZ = zsize
6164
- R = region
6265
- V = verbose
66+
- Wc = contour_pen
67+
- Wf = facade_pen
68+
- Wm = mesh_pen
6369
- c = panel
6470
- p = perspective
6571
- t = transparency
@@ -101,15 +107,15 @@ def grdview( # noqa: PLR0913
101107
102108
For any of these choices, you may force a monochrome image by appending the
103109
modifier **+m**.
104-
contourpen : str
110+
contour_pen
105111
Draw contour lines on top of surface or mesh (not image). Append pen attributes
106112
used for the contours.
107-
meshpen : str
108-
Set the pen attributes used for the mesh. You must also select ``surftype`` of
109-
**m** or **sm** for meshlines to be drawn.
110-
facadepen :str
113+
facade_pen
111114
Set the pen attributes used for the facade. You must also select ``plane`` for
112115
the facade outline to be drawn.
116+
mesh_pen
117+
Set the pen attributes used for the mesh. You must also select ``surftype`` of
118+
**m** or **sm** for meshlines to be drawn.
113119
shading : str
114120
Provide the name of a grid file with intensities in the (-1,+1) range, or a
115121
constant intensity to apply everywhere (affects the ambient light).
@@ -162,6 +168,9 @@ def grdview( # noqa: PLR0913
162168
aliasdict = AliasSystem(
163169
Jz=Alias(zscale, name="zscale"),
164170
JZ=Alias(zsize, name="zsize"),
171+
Wc=Alias(contour_pen, name="contour_pen"),
172+
Wf=Alias(facade_pen, name="facade_pen"),
173+
Wm=Alias(mesh_pen, name="mesh_pen"),
165174
).add_common(
166175
B=frame,
167176
J=projection,

pygmt/tests/test_grdview.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def test_grdview_surface_plot_styled_with_contourpen(xrgrid):
179179
surface plot.
180180
"""
181181
fig = Figure()
182-
fig.grdview(grid=xrgrid, cmap="relief", surftype="s", contourpen="0.5p,black,dash")
182+
fig.grdview(grid=xrgrid, cmap="relief", surftype="s", contour_pen="0.5p,black,dashed")
183183
return fig
184184

185185

@@ -190,7 +190,7 @@ def test_grdview_surface_mesh_plot_styled_with_meshpen(xrgrid):
190190
mesh plot.
191191
"""
192192
fig = Figure()
193-
fig.grdview(grid=xrgrid, cmap="relief", surftype="sm", meshpen="0.5p,black,dash")
193+
fig.grdview(grid=xrgrid, cmap="relief", surftype="sm", mesh_pen="0.5p,black,dashed")
194194
return fig
195195

196196

@@ -206,7 +206,7 @@ def test_grdview_on_a_plane_styled_with_facadepen(xrgrid):
206206
plane=100,
207207
perspective=[225, 30],
208208
zscale=0.005,
209-
facadepen="0.5p,blue,dash",
209+
facade_pen="0.5p,blue,dashed",
210210
)
211211
return fig
212212

0 commit comments

Comments
 (0)