2
2
legend - Plot a legend.
3
3
"""
4
4
5
+ from pygmt .alias import Alias , convert_aliases
5
6
from pygmt .clib import Session
6
7
from pygmt .exceptions import GMTInvalidInput
7
8
from pygmt .helpers import (
8
9
build_arg_string ,
9
10
data_kind ,
10
11
fmt_docstring ,
11
- kwargs_to_strings ,
12
- use_alias ,
13
12
)
14
13
15
14
16
15
@fmt_docstring
17
- @use_alias (
18
- R = "region" ,
19
- J = "projection" ,
20
- D = "position" ,
21
- F = "box" ,
22
- V = "verbose" ,
23
- c = "panel" ,
24
- p = "perspective" ,
25
- t = "transparency" ,
26
- )
27
- @kwargs_to_strings (R = "sequence" , c = "sequence_comma" , p = "sequence" )
28
- def legend (self , spec = None , position = "JTR+jTR+o0.2c" , box = "+gwhite+p1p" , ** kwargs ):
16
+ def legend (self , spec = None , position = "JTR+jTR+o0.2c" , box = "+gwhite+p1p" , ** kwargs ): # noqa: ARG001
29
17
r"""
30
18
Plot legends on maps.
31
19
@@ -37,8 +25,6 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg
37
25
38
26
Full option list at :gmt-docs:`legend.html`
39
27
40
- {aliases}
41
-
42
28
Parameters
43
29
----------
44
30
spec : None or str
@@ -67,12 +53,19 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg
67
53
{perspective}
68
54
{transparency}
69
55
"""
70
- kwargs = self ._preprocess (** kwargs )
56
+ _aliases = [
57
+ Alias ("region" , "R" , "" , "/" ),
58
+ Alias ("projection" , "J" , "" , "" ),
59
+ Alias ("position" , "D" , "" , "" ),
60
+ Alias ("box" , "F" , "" , "" ),
61
+ Alias ("verbose" , "v" , "" , "" ),
62
+ Alias ("panel" , "c" , "" , "," ),
63
+ Alias ("perspective" , "p" , "" , "/" ),
64
+ Alias ("transparency" , "t" , "" , "" ),
65
+ ]
71
66
72
- if kwargs .get ("D" ) is None :
73
- kwargs ["D" ] = position
74
- if kwargs .get ("F" ) is None :
75
- kwargs ["F" ] = box
67
+ kwargs = self ._preprocess (** kwargs )
68
+ options = convert_aliases ()
76
69
77
70
with Session () as lib :
78
71
if spec is None :
@@ -81,4 +74,6 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg
81
74
specfile = spec
82
75
else :
83
76
raise GMTInvalidInput (f"Unrecognized data type: { type (spec )} " )
84
- lib .call_module (module = "legend" , args = build_arg_string (kwargs , infile = specfile ))
77
+ lib .call_module (
78
+ module = "legend" , args = build_arg_string (options , infile = specfile )
79
+ )
0 commit comments