Skip to content
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
Add reverse (I) alias for makecpt
Used 'earth' cmap to test various reversed colormap examples.
  • Loading branch information
weiji14 committed Oct 4, 2019
commit 0abd81be9f7f23b4f1b397fba90cee28af8ee0db
9 changes: 8 additions & 1 deletion 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")
@use_alias(C="cmap", T="series", G="truncate", H="output", I="reverse")
@kwargs_to_strings(T="sequence", G="sequence")
def makecpt(**kwargs):
"""
Expand Down Expand Up @@ -39,6 +39,13 @@ def makecpt(**kwargs):
Optional. The file name with extension .cpt to store the generated CPT file.
If not given or False (default), saves the CPT as the session current CPT.

reverse (I) : str
Set this to True or c [Default] to reverse the sense of color progression in the
master CPT. Set this to z to reverse the sign of z-values in the color table.
Note that this change of z-direction happens before -G and -T values are used so
the latter must be compatible with the changed z-range. See also
:gmt-docs:`cookbook/features.html#manipulating-cpts`.

{aliases}
"""
with Session() as lib:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions pygmt/tests/test_makecpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,36 @@ def test_makecpt_truncated_at_zhigh_only(grid):
makecpt(cmap="rainbow", truncate=[None, 0.5], series=[-4500, 4500])
fig.grdimage(grid, projection="W0/6i")
return fig


@pytest.mark.mpl_image_compare
def test_makecpt_reverse_color_only(grid):
"""
Use static color palette table with its colors reversed
"""
fig = Figure()
makecpt(cmap="earth", reverse=True)
fig.grdimage(grid, projection="W0/6i")
return fig


@pytest.mark.mpl_image_compare
def test_makecpt_reverse_zsign_only(grid):
"""
Use static color palette table with its z-value sign reversed
"""
fig = Figure()
makecpt(cmap="earth", reverse="z")
fig.grdimage(grid, projection="W0/6i")
return fig


@pytest.mark.mpl_image_compare
def test_makecpt_reverse_color_and_zsign(grid):
"""
Use static color palette table with both its colors and z-value sign reversed
"""
fig = Figure()
makecpt(cmap="earth", reverse="cz")
fig.grdimage(grid, projection="W0/6i")
return fig