2
2
scalebar - Add a scale bar.
3
3
"""
4
4
5
+ from typing import Literal
6
+
5
7
from pygmt .alias import Alias , AliasSystem
6
8
from pygmt .clib import Session
7
9
from pygmt .helpers import build_arg_list
@@ -12,6 +14,7 @@ def scalebar( # noqa: PLR0913
12
14
self ,
13
15
position ,
14
16
length ,
17
+ position_type : Literal ["g" , "j" , "J" , "n" , "x" ] = "g" ,
15
18
label_alignment = None ,
16
19
scale_position = None ,
17
20
fancy = None ,
@@ -36,7 +39,8 @@ def scalebar( # noqa: PLR0913
36
39
>>> fig = pygmt.Figure()
37
40
>>> fig.basemap(region=[0, 80, -30, 30], projection="M10c", frame=True)
38
41
>>> fig.scalebar(
39
- ... "g10/10",
42
+ ... position=(10, 10),
43
+ ... position_type="g",
40
44
... length=1000,
41
45
... fancy=True,
42
46
... label="Scale",
@@ -45,9 +49,9 @@ def scalebar( # noqa: PLR0913
45
49
... )
46
50
>>> fig.show()
47
51
"""
48
- alias = AliasSystem (
52
+ kwdict = AliasSystem (
49
53
L = [
50
- Alias (position , separator = "/" ),
54
+ Alias (position , separator = "/" , prefix = position_type ),
51
55
Alias (length , prefix = "+w" ),
52
56
Alias (label_alignment , prefix = "+a" ),
53
57
Alias (scale_position , prefix = "+c" , separator = "/" ),
@@ -59,8 +63,8 @@ def scalebar( # noqa: PLR0913
59
63
Alias (vertical , prefix = "+v" ),
60
64
],
61
65
F = Alias (box ),
62
- )
66
+ ). kwdict
63
67
64
68
self ._preprocess ()
65
69
with Session () as lib :
66
- lib .call_module (module = "basemap" , args = build_arg_list (alias . kwdict ))
70
+ lib .call_module (module = "basemap" , args = build_arg_list (kwdict ))
0 commit comments