Skip to content

Commit 0f12972

Browse files
authored
Add shading to grdview gallery example (#506)
Adds shading to grdview gallery example, and adds alias "shading" for the I flag * Add shading to grdview gallery example * Add long form argument for shading
1 parent 216f5d2 commit 0f12972

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

examples/gallery/grid/grdview_surface.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
elevation angle of the view. We provide a list of two arguments to ``frame`` — the
99
second argument, prepended with ``"z"``, specifies the :math:`z`-axis frame attributes.
1010
Specifying the same scale for the ``projection`` and ``zcale`` arguments ensures equal
11-
axis scaling.
11+
axis scaling. The ``shading`` argument specifies illumination; here we choose an azimuth of
12+
45° with ``shading="+a45"``.
1213
"""
1314

1415
import pygmt
@@ -44,7 +45,8 @@ def ackley(x, y):
4445
zscale=f"{SCALE}i",
4546
surftype="s",
4647
cmap="roma",
47-
perspective="135/30",
48+
perspective=[135, 30], # Azimuth southeast (135°), at elevation 30°
49+
shading="+a45",
4850
)
4951

5052
fig.show()

pygmt/base_plotting.py

+10
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ def grdimage(self, grid, **kwargs):
336336
Wm="meshpen",
337337
Wf="facadepen",
338338
p="perspective",
339+
I="shading",
339340
)
340341
@kwargs_to_strings(R="sequence", p="sequence")
341342
def grdview(self, grid, **kwargs):
@@ -403,6 +404,15 @@ def grdview(self, grid, **kwargs):
403404
``'[x|y|z]azim[/elev[/zlevel]][+wlon0/lat0[/z0]][+vx0/y0]'``.
404405
Select perspective view.
405406
407+
shading : str
408+
Provide the name of a grid file with intensities in the (-1,+1)
409+
range, or a constant intensity to apply everywhere (affects the
410+
ambient light). Alternatively, derive an intensity grid from the
411+
input data grid reliefgrid via a call to ``grdgradient``; append
412+
``+aazimuth``, ``+nargs``, and ``+mambient`` to specify azimuth,
413+
intensity, and ambient arguments for that module, or just give
414+
``+d`` to select the default arguments (``+a-45+nt1+m0``).
415+
406416
"""
407417
kwargs = self._preprocess(**kwargs)
408418
kind = data_kind(grid, None, None)

0 commit comments

Comments
 (0)