Skip to content
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

Add inline example for grdview #2381

Merged
merged 9 commits into from
Mar 23, 2023
35 changes: 35 additions & 0 deletions pygmt/src/grdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use_alias,
)

__doctest_skip__ = ["grdview"]


@fmt_docstring
@use_alias(
Expand Down Expand Up @@ -117,6 +119,39 @@ def grdview(self, grid, **kwargs):
{interpolation}
{perspective}
{transparency}

Example
-------
>>> import pygmt
>>> # load the 15 arc-minutes grid with "gridline" registration
>>> # in a specified region
>>> grid = pygmt.datasets.load_earth_relief(
... resolution="15m",
... region=[-92.5, -82.5, -3, 7],
... registration="gridline",
... )
>>> # create a new plot with pygmt.Figure()
>>> fig = pygmt.Figure()
seisman marked this conversation as resolved.
Show resolved Hide resolved
>>> # create the contour plot
>>> fig.grdview(
... # pass in the grid downloaded above
... grid=grid,
... # set the perspective to have an azimuth of 130 and elevation of 30
seisman marked this conversation as resolved.
Show resolved Hide resolved
... perspective=[130, 30],
... # add a frame to the x- and y-axes
... # specify grid labels on the south and east borders of the plot
... frame=["xa", "ya", "wSnE"],
seisman marked this conversation as resolved.
Show resolved Hide resolved
... # set the projection to Mercator for the 10 cm figure
... projection="M10c",
yvonnefroehlich marked this conversation as resolved.
Show resolved Hide resolved
... # set the vertical scale (z-axis) to 2 cm
... zsize="2c",
... # set surface plot to plot CPT
... surftype="s",
seisman marked this conversation as resolved.
Show resolved Hide resolved
... # specify CPT to "geo"
... cmap="geo",
... )
>>> # show the plot
>>> fig.show()
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
with Session() as lib:
Expand Down