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 grdcontour #2148

Merged
merged 6 commits into from
Oct 9, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pygmt/src/grdcontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from pygmt.clib import Session
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias

__doctest_skip__ = ["grdcontour"]


@fmt_docstring
@use_alias(
Expand Down Expand Up @@ -95,6 +97,34 @@ def grdcontour(self, grid, **kwargs):
separator for the two labels instead.
{perspective}
{transparency}

willschlitzer marked this conversation as resolved.
Show resolved Hide resolved

Example
-------
>>> import pygmt
>>> # load the 15m 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",
... )
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved
>>> # create a new plot with pygmt.Figure()
>>> fig = pygmt.Figure()
>>> # create the contour plot
>>> fig.grdcontour(
... # pass in the grid downloaded above
... grid=grid,
... # set the interval for contour lines at 250 meters
... interval=250,
... # set the interval for annotated contour lines at 1,000 meters
... annotation=1000,
... # add a frame for the plot
... frame="a",
... # set the projection to Mercator for the 10 cm figure
... projection="M10c",
... )
>>> # show the plot
>>> fig.show()
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
with Session() as lib:
Expand Down