From d557810dfd63b5865d786642fe795f2c569854ae Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 17 Nov 2025 17:24:15 +0800 Subject: [PATCH 1/2] Figure.colorbar: Migrate the 'truncate' parameter to the new alias system --- pygmt/src/colorbar.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index 5cbcfec8da1..a2446b76ec9 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -7,19 +7,17 @@ from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session -from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias +from pygmt.helpers import build_arg_list, fmt_docstring, use_alias from pygmt.params import Box __doctest_skip__ = ["colorbar"] @fmt_docstring -@use_alias( - C="cmap", D="position", G="truncate", L="equalsize", Q="log", W="scale", Z="zfile" -) -@kwargs_to_strings(G="sequence", I="sequence") +@use_alias(C="cmap", D="position", L="equalsize", Q="log", W="scale", Z="zfile") def colorbar( self, + truncate: Sequence[float] | None = None, shading: float | Sequence[float] | bool = False, projection: str | None = None, box: Box | bool = False, @@ -59,6 +57,7 @@ def colorbar( {aliases} - B = frame - F = box + - G = truncate - I = shading - J = projection - R = region @@ -99,11 +98,11 @@ def colorbar( rectangular box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box appearance, pass a :class:`pygmt.params.Box` object to control style, fill, pen, and other box properties. - truncate : list or str - *zlo*/*zhi*. - Truncate the incoming CPT so that the lowest and highest z-levels are - to *zlo* and *zhi*. If one of these equal NaN then we leave that end of - the CPT alone. The truncation takes place before the plotting. + truncate + (*zlow*, *zhigh*). + Truncate the incoming CPT so that the lowest and highest z-levels are to *zlow* + and *zhigh*. If one of these equal NaN then we leave that end of the CPT alone. + The truncation takes place before the plotting. scale : float Multiply all z-values in the CPT by the provided scale. By default, the CPT is used as is. @@ -161,6 +160,7 @@ def colorbar( aliasdict = AliasSystem( F=Alias(box, name="box"), + G=Alias(truncate, name="truncate", sep="/", size=2), I=Alias(shading, name="shading", sep="/", size=2), ).add_common( B=frame, From 2e46cb87d0e051977c0a1a0e13db2d5bf697d449 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 17 Nov 2025 17:31:28 +0800 Subject: [PATCH 2/2] Fix a ruff issue --- pygmt/src/colorbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/colorbar.py b/pygmt/src/colorbar.py index a2446b76ec9..19ab7d413b6 100644 --- a/pygmt/src/colorbar.py +++ b/pygmt/src/colorbar.py @@ -15,7 +15,7 @@ @fmt_docstring @use_alias(C="cmap", D="position", L="equalsize", Q="log", W="scale", Z="zfile") -def colorbar( +def colorbar( # noqa: PLR0913 self, truncate: Sequence[float] | None = None, shading: float | Sequence[float] | bool = False,