88from pygmt ._typing import PathLike , TableLike
99from pygmt .alias import Alias , AliasSystem
1010from pygmt .clib import Session
11+ from pygmt .exceptions import GMTInvalidInput
1112from pygmt .helpers import build_arg_list , deprecate_parameter , fmt_docstring , use_alias
13+ from pygmt .params import Position
1214
1315
1416def _parse_fills (positive_fill , negative_fill ):
@@ -46,7 +48,6 @@ def _parse_fills(positive_fill, negative_fill):
4648 "fillnegative" , "negative_fill" , "v0.18.0" , remove_version = "v0.20.0"
4749)
4850@use_alias (
49- D = "position" ,
5051 T = "track" ,
5152 W = "pen" ,
5253 Z = "scale" ,
@@ -64,6 +65,10 @@ def wiggle( # noqa: PLR0913
6465 x = None ,
6566 y = None ,
6667 z = None ,
68+ position : Position | None = None ,
69+ length : float | str | None = None ,
70+ label : str | None = None ,
71+ label_alignment : Literal ["left" , "right" ] | None = None ,
6772 positive_fill = None ,
6873 negative_fill = None ,
6974 projection : str | None = None ,
@@ -107,29 +112,34 @@ def wiggle( # noqa: PLR0913
107112 $table_classes.
108113 Use parameter ``incols`` to choose which columns are x, y, z,
109114 respectively.
110- $projection
111- $region
115+ position
116+ Specify the position of the vertical scale bar on the plot. See
117+ :class:`pygmt.params.Position` for more details.
118+ length
119+ Length of the vertical scale bar in data (z) units.
120+ label
121+ Set the z unit label that is used in the scale label [Default is no unit].
122+ label_alignment
123+ Set the alignment of the scale label. Choose from ``"left"`` or ``"right"``
124+ [Default is ``"left"``].
112125 scale : str or float
113126 Give anomaly scale in data-units/distance-unit. Append **c**, **i**,
114127 or **p** to indicate the distance unit (centimeters, inches, or
115128 points); if no unit is given we use the default unit that is
116129 controlled by :gmt-term:`PROJ_LENGTH_UNIT`.
117- $frame
118- position : str
119- [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\
120- **+w**\ *length*\ [**+j**\ *justify*]\ [**+al**\|\ **r**]\
121- [**+o**\ *dx*\ [/*dy*]][**+l**\ [*label*]].
122- Define the reference point on the map for the vertical scale bar.
123130 positive_fill : str
124131 Set color or pattern for filling positive wiggles [Default is no fill].
125132 negative_fill : str
126133 Set color or pattern for filling negative wiggles [Default is no fill].
127134 track : str
128135 Draw track [Default is no track]. Append pen attributes to use
129136 [Default is ``"0.25p,black,solid"``].
130- $verbose
131137 pen : str
132138 Specify outline pen attributes [Default is no outline].
139+ $projection
140+ $region
141+ $frame
142+ $verbose
133143 $binary
134144 $panel
135145 $nodata
@@ -144,9 +154,29 @@ def wiggle( # noqa: PLR0913
144154 """
145155 self ._activate_figure ()
146156
157+ if isinstance (position , str ) and any (
158+ v is not None for v in (length , label , label_alignment )
159+ ):
160+ msg = (
161+ "Parameter 'position' is given with a raw GMT command string, and conflicts "
162+ "with parameters 'length', 'label', and 'label_alignment'."
163+ )
164+ raise GMTInvalidInput (msg )
165+
147166 _fills = _parse_fills (positive_fill , negative_fill )
148167
149168 aliasdict = AliasSystem (
169+ D = [
170+ Alias (position , name = "position" ),
171+ Alias (length , name = "length" , prefix = "+w" ),
172+ Alias (
173+ label_alignment ,
174+ name = "label_alignment" ,
175+ prefix = "+a" ,
176+ mapping = {"left" : "l" , "right" : "r" },
177+ ),
178+ Alias (label , name = "label" , prefix = "+l" ),
179+ ],
150180 G = Alias (_fills , name = "positive_fill/negative_fill" ),
151181 ).add_common (
152182 B = frame ,
0 commit comments