Skip to content

Commit cbca922

Browse files
committed
Alias truncate (G) for colorbar
Included one test for checking the truncation works to a min/max range. Also made sure region (R) is parsed as a slash separated sequence string.
1 parent 1e14c33 commit cbca922

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

pygmt/base_plotting.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,16 @@ def coast(self, **kwargs):
126126
lib.call_module("coast", build_arg_string(kwargs))
127127

128128
@fmt_docstring
129-
@use_alias(R="region", J="projection", B="frame", C="cmap", D="position", F="box")
130-
@kwargs_to_strings()
129+
@use_alias(
130+
R="region",
131+
J="projection",
132+
B="frame",
133+
C="cmap",
134+
D="position",
135+
F="box",
136+
G="truncate",
137+
)
138+
@kwargs_to_strings(R="sequence", G="sequence")
131139
def colorbar(self, **kwargs):
132140
"""
133141
Plot a gray or color scale-bar on maps.
Loading

pygmt/tests/test_colorbar.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,13 @@ def test_colorbar_box_with_offset_background():
128128
fig = Figure()
129129
fig.colorbar(cmap="rainbow", box="+s5p/-5p", position="x0c/0c+w1c/0.5c")
130130
return fig
131+
132+
133+
@pytest.mark.mpl_image_compare
134+
def test_colorbar_truncated_to_zlow_zhigh():
135+
"""
136+
Create colorbar truncated to z-low and z-high.
137+
"""
138+
fig = Figure()
139+
fig.colorbar(cmap="rainbow", truncate=[0.15, 0.85], position="x0c/0c+w2c/0.5c")
140+
return fig

0 commit comments

Comments
 (0)