Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
b73a6e2
Add the Box class for specifying box properties of embellishments
seisman Jul 14, 2025
9f08d1b
Apply suggestions from code review
seisman Jul 16, 2025
01b563c
Use Box in examples and tests
seisman Jul 16, 2025
d2ae10c
Use Box in examples and tests
seisman Jul 16, 2025
ec1af1d
Fix API doc
seisman Jul 26, 2025
48702b5
Clarify that subclass must implement the _aliases property
seisman Jul 27, 2025
210292f
Add validate method
seisman Jul 27, 2025
8e5321e
Fix the check logic
seisman Jul 27, 2025
926a690
Change to _validate
seisman Jul 27, 2025
b1c6330
Merge branch 'main' into AliasSystem/params/base
seisman Aug 3, 2025
bc31c7c
Remove unneeded comments
seisman Aug 3, 2025
de1545f
Rename separator to sep
seisman Aug 3, 2025
44b0be3
Merge branch 'main' into AliasSystem/params/base
seisman Aug 10, 2025
1d14eb5
Merge branch 'main' into AliasSystem/params/base
seisman Aug 21, 2025
6ddcf4e
Merge branch 'main' into AliasSystem/params/base
seisman Aug 22, 2025
84ca37e
Merge branch 'main' into AliasSystem/params/base
seisman Aug 24, 2025
0313330
Renanem the section header in doc api page
seisman Aug 24, 2025
40a47a8
Do not display False by default
seisman Aug 24, 2025
457abed
Fix repr
seisman Aug 24, 2025
16c3d6c
Merge branch 'main' into AliasSystem/params/base
seisman Aug 25, 2025
ab7ad67
Apply suggestions from code review
seisman Aug 26, 2025
3c1ee05
Merge branch 'main' into AliasSystem/params/base
seisman Aug 26, 2025
9d60637
Merge branch 'main' into AliasSystem/params/base
seisman Aug 29, 2025
c4a19a5
Apply suggestions from code review
seisman Aug 30, 2025
5ec1180
Check that inner_pen is set when inner_gap is set
seisman Aug 30, 2025
86d0a32
Fix the check of shading_offset and add a test
seisman Sep 3, 2025
4e98acf
Add more tests
seisman Sep 3, 2025
22fb1eb
Remove print statements
seisman Sep 3, 2025
a83f21d
Merge branch 'main' into AliasSystem/params/base
seisman Sep 3, 2025
dce0e47
Validate inner_pen/inner_gap in the _validate method
seisman Sep 3, 2025
078dffb
Merge branch 'main' into AliasSystem/params/base
seisman Sep 4, 2025
9b6ae97
Merge branch 'main' into AliasSystem/params/base
seisman Sep 4, 2025
e5ef5cf
Add more tests
seisman Sep 4, 2025
8250eb2
Add a real example
seisman Sep 4, 2025
81b2f4f
Merge remote-tracking branch 'origin/AliasSystem/params/base' into Al…
seisman Sep 4, 2025
4efc0f3
Rename shading_offset/shading_fill to shade_offset/shade_fill
seisman Sep 4, 2025
21a47b5
Improve the tests
seisman Sep 5, 2025
1229204
Add one more test
seisman Sep 5, 2025
30a795e
Merge branch 'main' into AliasSystem/params/base
seisman Sep 5, 2025
8deeb4d
Migrate the box parameter to the new alias system
seisman Aug 26, 2025
43fc33c
Back to the default postion and box for legend
seisman Sep 3, 2025
be888fc
Improve docstrings
seisman Sep 5, 2025
7eea687
Improve docstrings
seisman Sep 6, 2025
3a4b369
Order parameters [skip ci]
seisman Sep 7, 2025
9eb95fa
Use AbstractBaseClass
seisman Sep 7, 2025
c6bd16f
Fix issues after applying AbstractBaseClass
seisman Sep 7, 2025
5bc36c7
Skip the doctest in Box
seisman Sep 7, 2025
e26873d
CI: Access DagsHub repository via an access token
seisman Sep 6, 2025
f298379
No need to check length of private variables like _innerborder and _s…
seisman Sep 7, 2025
bd57dc0
Rename private property _shading to _shade
seisman Sep 7, 2025
a337503
Merge branch 'dvc/debug' into AliasSystem/params/base
seisman Sep 7, 2025
de26978
Merge branch 'AliasSystem/params/base' into AliasSystem/box
seisman Sep 7, 2025
ef3ba97
Merge branch 'main' into AliasSystem/box
seisman Sep 8, 2025
c094b02
Merge branch 'main' into AliasSystem/box
seisman Sep 9, 2025
b083028
Merge branch 'main' into AliasSystem/box
seisman Sep 10, 2025
94f49c1
Merge branch 'main' into AliasSystem/box
seisman Sep 13, 2025
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
28 changes: 9 additions & 19 deletions pygmt/src/coast.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
kwargs_to_strings,
use_alias,
)
from pygmt.params import Box

__doctest_skip__ = ["coast"]

Expand All @@ -24,7 +25,6 @@
B="frame",
C="lakes",
E="dcw",
F="box",
G="land",
I="rivers",
L="map_scale",
Expand All @@ -41,6 +41,7 @@ def coast(
resolution: Literal[
"auto", "full", "high", "intermediate", "low", "crude", None
] = None,
box: Box | bool = False,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
panel: int | tuple[int, int] | bool = False,
Expand Down Expand Up @@ -68,6 +69,7 @@ def coast(

{aliases}
- D = resolution
- F = box
- J = projection
- V = verbose
- c = panel
Expand Down Expand Up @@ -127,24 +129,11 @@ def coast(
map_scale : str
[**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\ **+w**\ *length*.
Draw a simple map scale centered on the reference point specified.
box : bool or str
[**+c**\ *clearances*][**+g**\ *fill*][**+i**\ [[*gap*/]\ *pen*]]\
[**+p**\ [*pen*]][**+r**\ [*radius*]][**+s**\ [[*dx*/*dy*/][*shade*]]].
If set to ``True``, draw a rectangular border around the
map scale or rose. Alternatively, specify a different pen with
**+p**\ *pen*. Add **+g**\ *fill* to fill the scale panel [Default is
no fill]. Append **+c**\ *clearance* where *clearance* is either gap,
xgap/ygap, or lgap/rgap/bgap/tgap where these items are uniform,
separate x and y, or individual side spacings between scale and
border. Append **+i** to draw a secondary, inner border as well.
We use a uniform gap between borders of 2 points and the
:gmt-term:`MAP_DEFAULTS_PEN` unless other values are specified. Append
**+r** to draw rounded rectangular borders instead, with a 6-points
corner radius. You can override this radius by appending another value.
Finally, append **+s** to draw an offset background shaded region.
Here, *dx/dy* indicates the shift relative to the foreground frame
[Default is ``"4p/-4p"``] and shade sets the fill style to use for
shading [Default is ``"gray50"``].
box
Draw a background box behind the map scale or rose. If set to ``True``, a simple
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.
borders : int, str, or list
*border*\ [/*pen*].
Draw political boundaries. Specify the type of boundary and
Expand Down Expand Up @@ -230,6 +219,7 @@ def coast(
"crude": "c",
},
),
F=Alias(box, name="box"),
).add_common(
J=projection,
V=verbose,
Expand Down
32 changes: 12 additions & 20 deletions pygmt/src/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

from typing import Literal

from pygmt.alias import AliasSystem
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.params import Box

__doctest_skip__ = ["colorbar"]

Expand All @@ -16,7 +17,6 @@
B="frame",
C="cmap",
D="position",
F="box",
G="truncate",
I="shading",
L="equalsize",
Expand All @@ -30,6 +30,7 @@
def colorbar(
self,
projection=None,
box: Box | bool = False,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
panel: int | tuple[int, int] | bool = False,
Expand All @@ -50,6 +51,7 @@ def colorbar(
Full GMT docs at :gmt-docs:`colorbar.html`.

{aliases}
- F = box
- J = projection
- V = verbose
- c = panel
Expand Down Expand Up @@ -82,23 +84,11 @@ def colorbar(
be changed by appending **+j** followed by a
:doc:`2-character justification code </techref/justification_codes>`
*justify*.
box : bool or str
[**+c**\ *clearances*][**+g**\ *fill*][**+i**\ [[*gap*/]\ *pen*]]\
[**+p**\ [*pen*]][**+r**\ [*radius*]][**+s**\ [[*dx*/*dy*/][*shade*]]].
If set to ``True``, draw a rectangular border around the color scale.
Alternatively, specify a different pen with **+p**\ *pen*. Add
**+g**\ *fill* to fill the scale panel [Default is no fill]. Append
**+c**\ *clearance* where *clearance* is either gap, xgap/ygap, or
lgap/rgap/bgap/tgap where these items are uniform, separate in x- and
y-direction, or individual side spacings between scale and border.
Append **+i** to draw a secondary, inner border as well. We use a
uniform gap between borders of 2p and the :gmt-term:`MAP_DEFAULTS_PEN`
unless other values are specified. Append **+r** to draw rounded
rectangular borders instead, with a 6p corner radius. You can override
this radius by appending another value. Finally, append **+s** to draw
an offset background shaded region. Here, *dx/dy* indicates the shift
relative to the foreground frame [Default is ``"4p/-4p"``] and shade
sets the fill style to use for shading [Default is ``"gray50"``].
box
Draw a background box behind the colorbar. If set to ``True``, a simple
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
Expand Down Expand Up @@ -157,7 +147,9 @@ def colorbar(
"""
self._activate_figure()

aliasdict = AliasSystem().add_common(
aliasdict = AliasSystem(
F=Alias(box, name="box"),
).add_common(
J=projection,
V=verbose,
c=panel,
Expand Down
28 changes: 13 additions & 15 deletions pygmt/src/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,20 @@
from typing import Literal

from pygmt._typing import PathLike
from pygmt.alias import AliasSystem
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.params import Box


@fmt_docstring
@use_alias(
D="position",
F="box",
G="bitcolor",
M="monochrome",
R="region",
p="perspective",
)
@use_alias(D="position", G="bitcolor", M="monochrome", R="region", p="perspective")
@kwargs_to_strings(R="sequence", p="sequence")
def image(
self,
imagefile: PathLike,
projection=None,
box: Box | bool = False,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
panel: int | tuple[int, int] | bool = False,
Expand All @@ -39,6 +34,7 @@ def image(
Full GMT docs at :gmt-docs:`image.html`.

{aliases}
- F = box
- J = projection
- V = verbose
- c = panel
Expand All @@ -59,11 +55,11 @@ def image(
**+w**\ [**-**]\ *width*\ [/*height*]\ [**+j**\ *justify*]\
[**+n**\ *nx*\ [/*ny*]]\ [**+o**\ *dx*\ [/*dy*]].
Set reference point on the map for the image.
box : bool or str
[**+c**\ *clearances*][**+g**\ *fill*][**+i**\ [[*gap*/]\ *pen*]]\
[**+p**\ [*pen*]][**+r**\ [*radius*]][**+s**\ [[*dx*/*dy*/][*shade*]]].
If set to ``True``, draw a rectangular border around the image
using :gmt-term:`MAP_FRAME_PEN`.
box
Draw a background box behind the image. If set to ``True``, a simple 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.
bitcolor : str or list
[*color*][**+b**\|\ **f**\|\ **t**].
Change certain pixel values to another color or make them transparent.
Expand All @@ -82,7 +78,9 @@ def image(
"""
self._activate_figure()

aliasdict = AliasSystem().add_common(
aliasdict = AliasSystem(
F=Alias(box, name="box"),
).add_common(
J=projection,
V=verbose,
c=panel,
Expand Down
43 changes: 13 additions & 30 deletions pygmt/src/inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@
import contextlib
from typing import Literal

from pygmt.alias import AliasSystem
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.params import Box

__doctest_skip__ = ["inset"]


@fmt_docstring
@contextlib.contextmanager
@use_alias(
D="position",
F="box",
M="margin",
N="no_clip",
R="region",
)
@use_alias(D="position", M="margin", N="no_clip", R="region")
@kwargs_to_strings(D="sequence", M="sequence", R="sequence")
def inset(
self,
projection=None,
box: Box | bool = False,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
**kwargs,
Expand All @@ -39,6 +35,7 @@ def inset(
Full GMT docs at :gmt-docs:`inset.html`.

{aliases}
- F = box
- J = projection
- V = verbose

Expand Down Expand Up @@ -83,27 +80,11 @@ def inset(
as *refpoint*, if **J** is used then *justify* defaults to the
mirror opposite of *refpoint*. Specify inset box attributes via
the ``box`` parameter [Default is outline only].
box : str or bool
[**+c**\ *clearances*][**+g**\ *fill*][**+i**\ [[*gap*/]\
*pen*]][**+p**\ [*pen*]][**+r**\ [*radius*]][**+s**\
[[*dx*/*dy*/][*shade*]]].
If set to ``True``, draw a rectangular box around the map
inset using the default pen; specify a different pen
with **+p**\ *pen*. Add **+g**\ *fill* to fill the inset box
[Default is no fill].
Append **+c**\ *clearance* where *clearance* is either
*gap*, *xgap*\ /\ *ygap*, or *lgap*\ /\ *rgap*\ /\ *bgap*\ /\
*tgap* where these items are uniform, separate in x- and
y-directions, or individual side spacings between map embellishment
and border. Append **+i** to draw a secondary, inner border as well.
We use a uniform *gap* between borders of 2p and the default pen
unless other values are specified. Append **+r** to draw rounded
rectangular borders instead, with a 6p corner radius. You
can override this radius by appending another value. Append
**+s** to draw an offset background shaded region. Here, *dx*/*dy*
indicates the shift relative to the foreground frame [Default is
``"4p/-4p"``] and *shade* sets the fill style to use for
shading [Default is ``"gray50"``].
box
Draw a background box behind the inset. If set to ``True``, a simple 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.
margin : float, str, or list
This is clearance that is added around the inside of the inset.
Plotting will take place within the inner region only. The margins
Expand Down Expand Up @@ -147,7 +128,9 @@ def inset(
"""
self._activate_figure()

aliasdict = AliasSystem().add_common(
aliasdict = AliasSystem(
F=Alias(box, name="box"),
).add_common(
J=projection,
V=verbose,
)
Expand Down
34 changes: 16 additions & 18 deletions pygmt/src/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Literal

from pygmt._typing import PathLike
from pygmt.alias import AliasSystem
from pygmt.alias import Alias, AliasSystem
from pygmt.clib import Session
from pygmt.exceptions import GMTTypeError
from pygmt.helpers import (
Expand All @@ -17,22 +17,18 @@
kwargs_to_strings,
use_alias,
)
from pygmt.params import Box


@fmt_docstring
@use_alias(
R="region",
D="position",
F="box",
p="perspective",
)
@use_alias(R="region", D="position", p="perspective")
@kwargs_to_strings(R="sequence", p="sequence")
def legend(
self,
spec: PathLike | io.StringIO | None = None,
projection=None,
position="JTR+jTR+o0.2c",
box="+gwhite+p1p",
box: Box | bool = False,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
panel: int | tuple[int, int] | bool = False,
Expand All @@ -51,6 +47,7 @@ def legend(
Full GMT docs at :gmt-docs:`legend.html`.

{aliases}
- F = box
- J = projection
- V = verbose
- c = panel
Expand All @@ -77,24 +74,23 @@ def legend(
legend. By default, uses **JTR**\ **+jTR**\ **+o**\ 0.2c which
places the legend at the top-right corner inside the map frame, with a
0.2 cm offset.
box : bool or str
[**+c**\ *clearances*][**+g**\ *fill*][**+i**\ [[*gap*/]\ *pen*]]\
[**+p**\ [*pen*]][**+r**\ [*radius*]][**+s**\ [[*dx*/*dy*/][*shade*]]].
If set to ``True``, draw a rectangular border around the legend
using :gmt-term:`MAP_FRAME_PEN`. By default, uses
**+g**\ white\ **+p**\ 1p which draws a box around the legend using a
1p black pen and adds a white background.
box
Draw a background box behind the legend. If set to ``True``, a simple
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.
{verbose}
{panel}
{perspective}
{transparency}
"""
self._activate_figure()

# Default position and box when not specified.
if kwargs.get("D") is None:
kwargs["D"] = position
if kwargs.get("F") is None:
kwargs["F"] = box
if box is False and kwargs.get("F") is None:
box = Box(pen="1p", fill="white") # Default box

kind = data_kind(spec)
if kind not in {"empty", "file", "stringio"}:
Expand All @@ -104,7 +100,9 @@ def legend(
type(spec), reason="Only one legend specification file is allowed."
)

aliasdict = AliasSystem().add_common(
aliasdict = AliasSystem(
F=Alias(box, name="box"),
).add_common(
J=projection,
V=verbose,
c=panel,
Expand Down
Loading
Loading