Skip to content

Commit 48c3c92

Browse files
authored
Figure.coast: Migrate the borders parameter to the new alias system and improve docstrings (#4257)
1 parent b1737f7 commit 48c3c92

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

pygmt/src/coast.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020

2121

2222
@fmt_docstring
23-
@use_alias(
24-
A="area_thresh", C="lakes", E="dcw", L="map_scale", N="borders", W="shorelines"
25-
)
23+
@use_alias(A="area_thresh", C="lakes", E="dcw", L="map_scale", W="shorelines")
2624
def coast( # noqa: PLR0913
2725
self,
2826
resolution: Literal[
@@ -31,6 +29,7 @@ def coast( # noqa: PLR0913
3129
land: str | None = None,
3230
water: str | None = None,
3331
rivers: int | str | Sequence[int | str] | None = None,
32+
borders: int | str | Sequence[int | str] | None = None,
3433
box: Box | bool = False,
3534
projection: str | None = None,
3635
frame: str | Sequence[str] | bool = False,
@@ -144,19 +143,26 @@ def coast( # noqa: PLR0913
144143
rectangular box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box
145144
appearance, pass a :class:`pygmt.params.Box` object to control style, fill, pen,
146145
and other box properties.
147-
borders : int, str, or list
148-
*border*\ [/*pen*].
149-
Draw political boundaries. Specify the type of boundary and
150-
[optionally] append pen attributes [Default is ``"0.25p,black,solid"``].
146+
borders
147+
Draw political boundaries. Specify the type of boundary to draw, and optionally
148+
append a pen attribute, in the format *border*\ /*pen* [Default pen is
149+
``"0.25p,black,solid"``]. Pass a sequence of border types or *border*\ /*pen*
150+
strings to draw different border types with different pens.
151+
152+
Choose from the following border types:
151153
152-
Choose from the list of boundaries below. Pass a list to ``borders`` to
153-
use multiple arguments.
154+
- ``1``: National boundaries
155+
- ``2``: State boundaries within the Americas
156+
- ``3``: Marine boundaries
157+
- ``"a"``: All boundaries (types ``1`` - ``3``)
154158
155-
- ``1``: national boundaries
156-
- ``2``: state boundaries within the Americas
157-
- ``3``: marine boundaries
158-
- ``"a"``: all boundaries (``1`` - ``3``)
159+
Example usage:
159160
161+
- ``borders=1``: Draw national boundaries with default pen.
162+
- ``borders="1/0.5p,red"``: Draw national boundaries with a 0.5-point red pen.
163+
- ``borders=["1/0.5p,red", "2/0.3p,blue,dashed"]``: Draw national boundaries
164+
with a 0.5-point red pen and state boundaries with a 0.3-point dashed blue
165+
pen.
160166
shorelines : bool, int, str, or list
161167
[*level*\ /]\ *pen*.
162168
Draw shorelines [Default is no shorelines]. Append pen attributes
@@ -212,11 +218,12 @@ def coast( # noqa: PLR0913
212218
kwargs.get("G", land) is None
213219
and kwargs.get("S", water) is None
214220
and kwargs.get("I", rivers) is None
215-
and not args_in_kwargs(args=["C", "N", "E", "Q", "W"], kwargs=kwargs)
221+
and kwargs.get("N", borders) is None
222+
and not args_in_kwargs(args=["C", "E", "Q", "W"], kwargs=kwargs)
216223
):
217224
msg = (
218225
"At least one of the following parameters must be specified: "
219-
"land, water, rivers, lakes, borders, dcw, Q, or shorelines."
226+
"land, water, rivers, borders, lakes, dcw, Q, or shorelines."
220227
)
221228
raise GMTInvalidInput(msg)
222229

@@ -236,6 +243,7 @@ def coast( # noqa: PLR0913
236243
F=Alias(box, name="box"),
237244
G=Alias(land, name="land"),
238245
I=Alias(rivers, name="rivers"),
246+
N=Alias(borders, name="borders"),
239247
S=Alias(water, name="water"),
240248
).add_common(
241249
B=frame,

0 commit comments

Comments
 (0)