55from collections .abc import Sequence
66from typing import Literal
77
8- from pygmt ._typing import PathLike , TableLike
8+ from pygmt ._typing import AnchorCode , PathLike , TableLike
99from pygmt .alias import Alias , AliasSystem
1010from pygmt .clib import Session
1111from pygmt .helpers import build_arg_list , deprecate_parameter , fmt_docstring , use_alias
12+ from pygmt .params import Position
13+ from pygmt .src ._common import _parse_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 | Sequence [float | str ] | AnchorCode | 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 ,
@@ -72,8 +77,8 @@ def wiggle( # noqa: PLR0913
7277 verbose : Literal ["quiet" , "error" , "warning" , "timing" , "info" , "compat" , "debug" ]
7378 | bool = False ,
7479 panel : int | Sequence [int ] | bool = False ,
75- transparency : float | None = None ,
7680 perspective : float | Sequence [float ] | str | bool = False ,
81+ transparency : float | None = None ,
7782 incols : int | str | Sequence [int | str ] | None = None ,
7883 ** kwargs ,
7984):
@@ -89,6 +94,7 @@ def wiggle( # noqa: PLR0913
8994
9095 $aliases
9196 - B = frame
97+ - D = **+w**: length, **+l**: label, **+a**: label_alignment
9298 - G = **+p**: positive_fill, **+n**: negative_fill
9399 - J = projection
94100 - R = region
@@ -107,29 +113,45 @@ def wiggle( # noqa: PLR0913
107113 $table_classes.
108114 Use parameter ``incols`` to choose which columns are x, y, z,
109115 respectively.
110- $projection
111- $region
116+
117+ position
118+ Position of the vertical scale on the plot. It can be specified in multiple
119+ ways:
120+
121+ - A :class:`pygmt.params.Position` object to fully control the reference point,
122+ anchor point, and offset.
123+ - A sequence of two values representing the x- and y- coordinates in plot
124+ coordinates, e.g., ``(1, 2)`` or ``("1c", "2c")``.
125+ - A :doc:`2-character justification code </techref/justification_codes>` for a
126+ position inside the plot, e.g., ``"TL"`` for Top Left corner inside the plot.
127+
128+ If not specified, defaults to the Bottom Left corner of the plot with a 0.2-cm
129+ offset.
130+ length
131+ Length of the vertical scale bar in data (z) units.
132+ label
133+ Set the z unit label that is used in the scale label [Default is no unit].
134+ label_alignment
135+ Set the alignment of the scale label. Choose from ``"left"`` or ``"right"``
136+ [Default is ``"left"``].
112137 scale : str or float
113138 Give anomaly scale in data-units/distance-unit. Append **c**, **i**,
114139 or **p** to indicate the distance unit (centimeters, inches, or
115140 points); if no unit is given we use the default unit that is
116141 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.
123142 positive_fill : str
124143 Set color or pattern for filling positive wiggles [Default is no fill].
125144 negative_fill : str
126145 Set color or pattern for filling negative wiggles [Default is no fill].
127146 track : str
128147 Draw track [Default is no track]. Append pen attributes to use
129148 [Default is ``"0.25p,black,solid"``].
130- $verbose
131149 pen : str
132150 Specify outline pen attributes [Default is no outline].
151+ $projection
152+ $region
153+ $frame
154+ $verbose
133155 $binary
134156 $panel
135157 $nodata
@@ -144,9 +166,26 @@ def wiggle( # noqa: PLR0913
144166 """
145167 self ._activate_figure ()
146168
169+ position = _parse_position (
170+ position ,
171+ kwdict = {"length" : length , "label" : label , "label_alignment" : label_alignment },
172+ default = Position ("BL" , offset = 0.2 ), # Default to BL with 0.2-cm offset.
173+ )
174+
147175 _fills = _parse_fills (positive_fill , negative_fill )
148176
149177 aliasdict = AliasSystem (
178+ D = [
179+ Alias (position , name = "position" ),
180+ Alias (length , name = "length" , prefix = "+w" ),
181+ Alias (
182+ label_alignment ,
183+ name = "label_alignment" ,
184+ prefix = "+a" ,
185+ mapping = {"left" : "l" , "right" : "r" },
186+ ),
187+ Alias (label , name = "label" , prefix = "+l" ),
188+ ],
150189 G = Alias (_fills , name = "positive_fill/negative_fill" ),
151190 ).add_common (
152191 B = frame ,
0 commit comments