Skip to content

Commit

Permalink
Alias continuous (Z) for makecpt
Browse files Browse the repository at this point in the history
Included one test to create a continuous cpt from blue to white. Also updated link to the full list of GMT's color palette tables due to documentation reorganization during GenericMappingTools/gmt#1594.
  • Loading branch information
weiji14 committed Oct 7, 2019
1 parent 0abd81b commit c22d065
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pygmt/mathops.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@fmt_docstring
@use_alias(C="cmap", T="series", G="truncate", H="output", I="reverse")
@use_alias(C="cmap", T="series", G="truncate", H="output", I="reverse", Z="continuous")
@kwargs_to_strings(T="sequence", G="sequence")
def makecpt(**kwargs):
"""
Expand All @@ -20,7 +20,7 @@ def makecpt(**kwargs):
cmap (C) : str
Selects the master color palette table (CPT) to use in the interpolation.
Full list of built-in color palette tables can be found at
:gmt-docs:`GMT_Docs.html#built-in-color-palette-tables-cpt`.
:gmt-docs:`cookbook/cpts.html#built-in-color-palette-tables-cpt`.
series (T) : list or str
``[min/max/inc[+b|l|n]|file|list]``.
Expand All @@ -46,6 +46,12 @@ def makecpt(**kwargs):
the latter must be compatible with the changed z-range. See also
:gmt-docs:`cookbook/features.html#manipulating-cpts`.
continuous (Z) : bool
Creates a continuous CPT [Default is discontinuous, i.e., constant colors for
each interval]. This option has no effect when no -T is used, or when using
-Tz_min/z_max; in the first case the input CPT remains untouched, in the second
case it is only scaled to match the range z_min/z_max.
{aliases}
"""
with Session() as lib:
Expand Down
Binary file added pygmt/tests/baseline/test_makecpt_continuous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions pygmt/tests/test_makecpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,15 @@ def test_makecpt_reverse_color_and_zsign(grid):
makecpt(cmap="earth", reverse="cz")
fig.grdimage(grid, projection="W0/6i")
return fig


@pytest.mark.mpl_image_compare
def test_makecpt_continuous(grid):
"""
Use static color palette table that is continuous from blue to white and scaled from
-4500 to 4500m.
"""
fig = Figure()
makecpt(cmap="blue,white", continuous=True, series="-4500,4500")
fig.grdimage(grid, projection="W0/6i")
return fig

0 comments on commit c22d065

Please sign in to comment.