Skip to content

Commit 818dfa5

Browse files
willschlitzerseismanmichaelgrundyvonnefroehlich
authored
Add inline example for grdview (#2381)
Co-authored-by: Dongdong Tian <[email protected]> Co-authored-by: Michael Grund <[email protected]> Co-authored-by: Yvonne Fröhlich <[email protected]>
1 parent d03862b commit 818dfa5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

pygmt/src/grdview.py

+35
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use_alias,
1414
)
1515

16+
__doctest_skip__ = ["grdview"]
17+
1618

1719
@fmt_docstring
1820
@use_alias(
@@ -117,6 +119,39 @@ def grdview(self, grid, **kwargs):
117119
{interpolation}
118120
{perspective}
119121
{transparency}
122+
123+
Example
124+
-------
125+
>>> import pygmt
126+
>>> # load the 30 arc-minutes grid with "gridline" registration
127+
>>> # in a specified region
128+
>>> grid = pygmt.datasets.load_earth_relief(
129+
... resolution="30m",
130+
... region=[-92.5, -82.5, -3, 7],
131+
... registration="gridline",
132+
... )
133+
>>> # create a new figure instance with pygmt.Figure()
134+
>>> fig = pygmt.Figure()
135+
>>> # create the contour plot
136+
>>> fig.grdview(
137+
... # pass in the grid downloaded above
138+
... grid=grid,
139+
... # set the perspective to an azimuth of 130° and an elevation of 30°
140+
... perspective=[130, 30],
141+
... # add a frame to the x- and y-axes
142+
... # specify annotations on the south and east borders of the plot
143+
... frame=["xa", "ya", "wSnE"],
144+
... # set the projection of the 2-D map to Mercator with a 10 cm width
145+
... projection="M10c",
146+
... # set the vertical scale (z-axis) to 2 cm
147+
... zsize="2c",
148+
... # set "surface plot" to color the surface via a CPT
149+
... surftype="s",
150+
... # specify CPT to "geo"
151+
... cmap="geo",
152+
... )
153+
>>> # show the plot
154+
>>> fig.show()
120155
"""
121156
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
122157
with Session() as lib:

0 commit comments

Comments
 (0)