Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions examples/tutorials/advanced/cartesian_histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
# Grouped bars
# ------------
#
# By setting the ``barwidth`` parameter in respect to the values passed to the
# By setting the ``bar_width`` parameter in respect to the values passed to the
# ``series`` parameter histograms with grouped bars can be created.
#
# Limitations of histograms with grouped bars are:
Expand All @@ -347,7 +347,7 @@
# of the bin width
# Offset ("+o") the bars to align each bar with the left limit of the corresponding
# bin
barwidth=f"{binwidth / 2}+o-{binwidth / 4}",
bar_width=f"{binwidth / 2}+o-{binwidth / 4}",
label="data01",
)

Expand All @@ -358,7 +358,7 @@
fill="orange",
pen="1p,darkgray,solid",
histtype=0,
barwidth=f"{binwidth / 2}+o{binwidth / 4}",
bar_width=f"{binwidth / 2}+o{binwidth / 4}",
label="data02",
)

Expand Down
13 changes: 10 additions & 3 deletions pygmt/src/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@
from pygmt._typing import PathLike, TableLike
from pygmt.alias import 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,
deprecate_parameter,
fmt_docstring,
kwargs_to_strings,
use_alias,
)


@fmt_docstring
@deprecate_parameter("barwidth", "bar_width", "v0.18.0", remove_version="v0.20.0")
@use_alias(
A="horizontal",
C="cmap",
D="annotate",
E="barwidth",
E="bar_width",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about split this option into two parameter bar_width and bar_offset?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make the code more Pythonic and readable.

Copy link
Member

@seisman seisman Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you interested in working on this? It's a good time to get familiar with the new alias system.

Better to do it in a separate PR, so that we can have two entries in the changelog, one for the deprecation, one for the enhancement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Will give it a try 🙂.

F="center",
G="fill",
L="extreme",
Expand Down Expand Up @@ -84,7 +91,7 @@ def histogram(
annotation font; use **+o** to change the offset between bar and
label [Default is ``"6p"``]; use **+r** to rotate the labels from
horizontal to vertical.
barwidth : float or str
bar_width : float or str
*width*\ [**+o**\ *offset*].
Use an alternative histogram bar width than the default set via
``series``, and optionally shift all bars by an *offset*. Here
Expand Down