From 4120c84e0d5458c2d23c3286fbfa090d54492b3a Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 7 Sep 2026 16:56:26 +0800 Subject: [PATCH 1/2] Figure.histogram: Let parameter 'extreme' support Pythonic arguments --- pygmt/src/histogram.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index b06e4b15737..22996c24fa8 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -22,7 +22,6 @@ @use_alias( D="annotate", F="center", - L="extreme", N="distribution", Q="cumulative", S="stairs", @@ -45,6 +44,7 @@ def histogram( pen: str | None = None, fill: str | None = None, horizontal: bool = False, + extreme: Literal["low", "high", "both"] | None = None, projection: str | None = None, region: Sequence[float | str] | str | None = None, frame: Frame | Axis | Literal["none"] | str | Sequence[str] | bool = False, @@ -68,6 +68,7 @@ def histogram( - E = bar_width, **+o**: bar_offset - G = fill - J = projection + - L = extreme - R = region - V = verbose - W = pen @@ -117,14 +118,13 @@ def histogram( [**r**]. Draw a cumulative histogram by passing ``True``. Use **r** to display a reverse cumulative histogram. - extreme : str - **l**\|\ **h**\|\ **b**. - The modifiers specify the handling of extreme values that fall outside - the range set by ``series``. By default, these values are ignored. - Append **b** to let these values be included in the first or last - bins. To only include extreme values below first bin into the first - bin, use **l**, and to only include extreme values above the last bin - into that last bin, use **h**. + extreme + Handle extreme values that fall outside the range set by ``series``. By default, + these values are ignored. Valid values are: + + - ``"first"``: only include extreme values below first bin into the first bin + - ``"last"``: only include extreme values above the last bin into that last bin + - ``"both"``: include extreme values into the first or last bins stairs : bool Draw a stairs-step diagram which does not include the internal bars of the default histogram. @@ -176,6 +176,9 @@ def histogram( Alias(bar_offset, name="bar_offset", prefix="+o"), ], G=Alias(fill, name="fill"), + L=Alias( + extreme, name="extreme", mapping={"first": "l", "last": "h", "both": "b"} + ), W=Alias(pen, name="pen"), ).add_common( B=frame, From 04681a01c6535cea4d1c6f3a18c98bd18780e5ef Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 7 Sep 2026 17:25:05 +0800 Subject: [PATCH 2/2] Fix type hints --- pygmt/src/histogram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index 22996c24fa8..f07b674ee85 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -44,7 +44,7 @@ def histogram( pen: str | None = None, fill: str | None = None, horizontal: bool = False, - extreme: Literal["low", "high", "both"] | None = None, + extreme: Literal["first", "last", "both"] | None = None, projection: str | None = None, region: Sequence[float | str] | str | None = None, frame: Frame | Axis | Literal["none"] | str | Sequence[str] | bool = False,