Skip to content

Commit

Permalink
Add inline example for grd2cpt (#2145)
Browse files Browse the repository at this point in the history
Co-authored-by: Yvonne Fröhlich <[email protected]>
  • Loading branch information
willschlitzer and yvonnefroehlich authored Oct 20, 2022
1 parent 0dd309a commit 5a967f9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pygmt/src/grd2cpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit 5a967f9

Please sign in to comment.