From 52e1e2c0792b41e582e792ed231af7d517a4fada Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 4 Sep 2026 17:30:22 +0800 Subject: [PATCH 1/4] v1 --- pygmt/src/histogram.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index 67d9b6d1009..dfb02d983f2 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -30,7 +30,6 @@ S="stairs", T="series", W="pen", - Z="histtype", b="binary", d="nodata", e="find", @@ -45,6 +44,9 @@ def histogram( bar_width: float | str | None = None, bar_offset: float | str | None = None, cmap: str | bool = False, + histtype: Literal[ + "counts", "freq", "log_count", "log_freq", "log10_count", "log10_freq" + ] = "counts", projection: str | None = None, region: Sequence[float | str] | str | None = None, frame: Frame | Axis | Literal["none"] | str | Sequence[str] | bool = False, @@ -68,6 +70,7 @@ def histogram( - J = projection - R = region - V = verbose + - Z = histtype - c = panel - i = incols - p = perspective @@ -130,19 +133,15 @@ def histogram( series : int, str, or list [*min*\ /*max*\ /]\ *inc*\ [**+n**\ ]. Set the interval for the width of each bar in the histogram. - histtype : int or str - [*type*][**+w**]. - Choose between 6 types of histograms: + histtype + The histogram type to plot: - * 0 = counts [Default] - * 1 = frequency_percent - * 2 = log (1.0 + count) - * 3 = log (1.0 + frequency_percent) - * 4 = log10 (1.0 + count) - * 5 = log10 (1.0 + frequency_percent). - - To use weights provided as a second data column instead of pure counts, - append **+w**. + - ``"counts"``: counts [Default] + - ``"freq"``: frequency_percent + - ``"log_count"``: log (1.0 + count) + - ``"log_freq"``: log (1.0 + frequency_percent) + - ``"log10_count"``: log10 (1.0 + count) + - ``"log10_freq"``: log10 (1.0 + frequency_percent $projection $region $frame @@ -169,6 +168,18 @@ def histogram( Alias(bar_width, name="bar_width"), Alias(bar_offset, name="bar_offset", prefix="+o"), ], + Z=Alias( + histtype, + name="histtype", + mapping={ + "counts": "0", + "freq": "1", + "log_count": "2", + "log_freq": "3", + "log10_count": "4", + "log10_freq": "5", + }, + ), ).add_common( B=frame, J=projection, From 6bf79b3e4648906394f72d2dcf0b9e1b096738ba Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 22 Sep 2026 12:14:24 +0800 Subject: [PATCH 2/4] Fix type hints --- pygmt/src/histogram.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index 897ff81080d..f550d72309c 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -40,8 +40,8 @@ def histogram( self, data: PathLike | TableLike, histtype: Literal[ - "counts", "freq", "log_count", "log_freq", "log10_count", "log10_freq" - ] = "counts", + "count", "percent", "log_count", "log_percent", "log10_count", "log10_percent" + ] = "count", bar_width: float | str | None = None, bar_offset: float | str | None = None, cmap: str | bool = False, @@ -207,7 +207,7 @@ def histogram( histtype, name="histtype", mapping={ - "counts": "0", + "count": "0", "percent": "1", "log_count": "2", "log_percent": "3", From 75ea4bfe3e801d686b517c855393e311c0dc6ba9 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 22 Sep 2026 12:14:37 +0800 Subject: [PATCH 3/4] Fix docstrings --- 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 f550d72309c..971c02fc968 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -95,7 +95,7 @@ def histogram( histtype The histogram type to plot: - - ``"counts"``: counts [Default] + - ``"count"``: counts [Default] - ``"percent"``: frequency_percent - ``"log_count"``: log (1.0 + count) - ``"log_percent"``: log (1.0 + frequency_percent) From ea1cb1b1e3c35e0a78d2757b25c9f9fa3cb6a42b Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 22 Sep 2026 12:16:48 +0800 Subject: [PATCH 4/4] Figure.histogram: Support Pythonic arguments for the 'histtype' parameter --- pygmt/src/histogram.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pygmt/src/histogram.py b/pygmt/src/histogram.py index 971c02fc968..b0822c4fd91 100644 --- a/pygmt/src/histogram.py +++ b/pygmt/src/histogram.py @@ -207,12 +207,12 @@ def histogram( histtype, name="histtype", mapping={ - "count": "0", - "percent": "1", - "log_count": "2", - "log_percent": "3", - "log10_count": "4", - "log10_percent": "5", + "count": 0, + "percent": 1, + "log_count": 2, + "log_percent": 3, + "log10_count": 4, + "log10_percent": 5, }, ), ).add_common(