Skip to content

Commit 9a19c1a

Browse files
authored
Merge branch 'main' into params/position
2 parents 90c7ea2 + b1737f7 commit 9a19c1a

2 files changed

Lines changed: 58 additions & 43 deletions

File tree

pygmt/src/coast.py

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@
2121

2222
@fmt_docstring
2323
@use_alias(
24-
A="area_thresh",
25-
C="lakes",
26-
E="dcw",
27-
I="rivers",
28-
L="map_scale",
29-
N="borders",
30-
W="shorelines",
24+
A="area_thresh", C="lakes", E="dcw", L="map_scale", N="borders", W="shorelines"
3125
)
3226
def coast( # noqa: PLR0913
3327
self,
@@ -36,6 +30,7 @@ def coast( # noqa: PLR0913
3630
] = None,
3731
land: str | None = None,
3832
water: str | None = None,
33+
rivers: int | str | Sequence[int | str] | None = None,
3934
box: Box | bool = False,
4035
projection: str | None = None,
4136
frame: str | Sequence[str] | bool = False,
@@ -71,6 +66,7 @@ def coast( # noqa: PLR0913
7166
- D = resolution
7267
- F = box
7368
- G = land
69+
- I = rivers
7470
- J = projection
7571
- R = region
7672
- S = water
@@ -103,35 +99,43 @@ def coast( # noqa: PLR0913
10399
Select filling of "dry" areas.
104100
water
105101
Select filling of "wet" areas.
106-
rivers : int, str, or list
107-
*river*\ [/*pen*].
108-
Draw rivers. Specify the type of rivers and [optionally] append
109-
pen attributes [Default is ``"0.25p,black,solid"``].
110-
111-
Choose from the list of river types below; pass a list to ``rivers``
112-
to use multiple arguments.
113-
114-
- ``0``: double-lined rivers (river-lakes)
115-
- ``1``: permanent major rivers
116-
- ``2``: additional major rivers
117-
- ``3``: additional rivers
118-
- ``4``: minor rivers
119-
- ``5``: intermittent rivers - major
120-
- ``6``: intermittent rivers - additional
121-
- ``7``: intermittent rivers - minor
122-
- ``8``: major canals
123-
- ``9``: minor canals
124-
- ``10``: irrigation canals
125-
126-
You can also choose from several preconfigured river groups:
127-
128-
- ``"a"``: rivers and canals (``0`` - ``10``)
129-
- ``"A"``: rivers and canals except river-lakes (``1`` - ``10``)
130-
- ``"r"``: permanent rivers (``0`` - ``4``)
131-
- ``"R"``: permanent rivers except river-lakes (``1`` - ``4``)
132-
- ``"i"``: intermittent rivers (``5`` - ``7``)
133-
- ``"c"``: canals (``8`` - ``10``)
134-
102+
rivers
103+
Draw rivers. Specify the type of rivers to draw, and optionally append a pen
104+
attribute, in the format *river*\ /*pen* [Default pen is
105+
``"0.25p,black,solid"``]. Pass a sequence of river types or *river*\ /*pen*
106+
strings to draw different river types with different pens.
107+
108+
Choose from the following river types:
109+
110+
- ``0``: Double-lined rivers (river-lakes)
111+
- ``1``: Permanent major rivers
112+
- ``2``: Additional major rivers
113+
- ``3``: Additional rivers
114+
- ``4``: Minor rivers
115+
- ``5``: Intermittent rivers - major
116+
- ``6``: Intermittent rivers - additional
117+
- ``7``: Intermittent rivers - minor
118+
- ``8``: Major canals
119+
- ``9``: Minor canals
120+
- ``10``: Irrigation canals
121+
122+
Or choose from the following preconfigured river groups:
123+
124+
- ``"a"``: All rivers and canals (types ``0`` - ``10``)
125+
- ``"A"``: Rivers and canals except river-lakes (types ``1`` - ``10``)
126+
- ``"r"``: Permanent rivers (types ``0`` - ``4``)
127+
- ``"R"``: Permanent rivers except river-lakes (types ``1`` - ``4``)
128+
- ``"i"``: Intermittent rivers (types ``5`` - ``7``)
129+
- ``"c"``: Canals (types ``8`` - ``10``)
130+
131+
Example usage:
132+
133+
- ``rivers=1``: Draw permanent major rivers with default pen.
134+
- ``rivers="1/0.5p,blue"``: Draw permanent major rivers with a 0.5-point blue
135+
pen.
136+
- ``rivers=["1/0.5p,blue", "5/0.3p,cyan,dashed"]``: Draw permanent major rivers
137+
with a 0.5-point blue pen and intermittent major rivers with a 0.3-point
138+
dashed cyan pen.
135139
map_scale : str
136140
[**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\ **+w**\ *length*.
137141
Draw a simple map scale centered on the reference point specified.
@@ -207,11 +211,12 @@ def coast( # noqa: PLR0913
207211
if (
208212
kwargs.get("G", land) is None
209213
and kwargs.get("S", water) is None
210-
and not args_in_kwargs(args=["C", "I", "N", "E", "Q", "W"], kwargs=kwargs)
214+
and kwargs.get("I", rivers) is None
215+
and not args_in_kwargs(args=["C", "N", "E", "Q", "W"], kwargs=kwargs)
211216
):
212217
msg = (
213218
"At least one of the following parameters must be specified: "
214-
"land, water, lakes, rivers, borders, dcw, Q, or shorelines."
219+
"land, water, rivers, lakes, borders, dcw, Q, or shorelines."
215220
)
216221
raise GMTInvalidInput(msg)
217222

@@ -230,6 +235,7 @@ def coast( # noqa: PLR0913
230235
),
231236
F=Alias(box, name="box"),
232237
G=Alias(land, name="land"),
238+
I=Alias(rivers, name="rivers"),
233239
S=Alias(water, name="water"),
234240
).add_common(
235241
B=frame,

pygmt/src/legend.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222

2323
@fmt_docstring
2424
@use_alias(D="position")
25-
def legend(
25+
def legend( # noqa: PLR0913
2626
self,
2727
spec: PathLike | io.StringIO | None = None,
28-
projection: str | None = None,
29-
region: Sequence[float | str] | str | None = None,
28+
scale: float | None = None,
3029
position="JTR+jTR+o0.2c",
3130
box: Box | bool = False,
31+
projection: str | None = None,
32+
region: Sequence[float | str] | str | None = None,
33+
frame: str | Sequence[str] | bool = False,
3234
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
3335
| bool = False,
3436
panel: int | Sequence[int] | bool = False,
@@ -48,9 +50,11 @@ def legend(
4850
Full GMT docs at :gmt-docs:`legend.html`.
4951
5052
$aliases
53+
- B = frame
5154
- F = box
5255
- J = projection
5356
- R = region
57+
- S = scale
5458
- V = verbose
5559
- c = panel
5660
- p = perspective
@@ -67,8 +71,6 @@ def legend(
6771
- A :class:`io.StringIO` object containing the legend specification
6872
6973
See :gmt-docs:`legend.html` for the definition of the legend specification.
70-
$projection
71-
$region
7274
position : str
7375
[**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\
7476
**+w**\ *width*\ [/*height*]\ [**+j**\ *justify*]\ [**+l**\ *spacing*]\
@@ -82,6 +84,11 @@ def legend(
8284
rectangular box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box
8385
appearance, pass a :class:`pygmt.params.Box` object to control style, fill, pen,
8486
and other box properties.
87+
scale
88+
Scale all symbol sizes by a common scale [Default is 1.0, i.e., no scaling].
89+
$projection
90+
$region
91+
$frame
8592
$verbose
8693
$panel
8794
$perspective
@@ -105,7 +112,9 @@ def legend(
105112

106113
aliasdict = AliasSystem(
107114
F=Alias(box, name="box"),
115+
S=Alias(scale, name="scale"),
108116
).add_common(
117+
B=frame,
109118
J=projection,
110119
R=region,
111120
V=verbose,

0 commit comments

Comments
 (0)