From 5a967f98565e756ecf587b8e7ed1d2fdf05bec43 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 19 Oct 2022 22:04:17 -0400 Subject: [PATCH] Add inline example for grd2cpt (#2145) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/grd2cpt.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pygmt/src/grd2cpt.py b/pygmt/src/grd2cpt.py index 8452c3f1fee..06726705720 100644 --- a/pygmt/src/grd2cpt.py +++ b/pygmt/src/grd2cpt.py @@ -6,6 +6,8 @@ from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias +__doctest_skip__ = ["grd2cpt"] + @fmt_docstring @use_alias( @@ -159,6 +161,20 @@ def grd2cpt(grid, **kwargs): range. Note that ``cyclic=True`` cannot be set together with ``categorical=True``. {verbose} + + Example + ------- + >>> import pygmt + >>> # load the 30 arc minute grid with "gridline" registration + >>> grid = pygmt.datasets.load_earth_relief("30m", registration="gridline") + >>> # create a plot + >>> fig = pygmt.Figure() + >>> # create a CPT from the grid object with grd2cpt + >>> pygmt.grd2cpt(grid=grid) + >>> # plot the grid object, the CPT will be automatically used + >>> fig.grdimage(grid=grid) + >>> # show the plot + >>> fig.show() """ if kwargs.get("W") is not None and kwargs.get("Ww") is not None: raise GMTInvalidInput("Set only categorical or cyclic to True, not both.")