Skip to content

Figure.wiggle: Refactor using the new alias system #4049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions pygmt/src/wiggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
wiggle - Plot z=f(x,y) anomalies along tracks.
"""

from pygmt._typing import PathLike, TableLike
from collections.abc import Sequence
from typing import Literal

from pygmt._typing import AnchorCode, PathLike, TableLike
from pygmt.alias import Alias, AliasSystem
from pygmt.clib import Session
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias
Expand Down Expand Up @@ -31,7 +34,7 @@
w="wrap",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence")
def wiggle(
def wiggle( # noqa: PLR0913
self,
data: PathLike | TableLike | None = None,
x=None,
Expand All @@ -40,6 +43,15 @@ def wiggle(
fillpositive=None,
fillnegative=None,
projection=None,
position: Sequence[str | float] | AnchorCode = None,
position_type: Literal[
"mapcoords", "boxcoords", "plotcoords", "inside", "outside"
] = "mapcoords",
length=None,
justify: AnchorCode = None,
anchor_offset=None,
label_position=None,
unit=None,
**kwargs,
):
r"""
Expand Down Expand Up @@ -111,6 +123,30 @@ def wiggle(
kwargs["G"].append(fillnegative + "+n")

aliasdict = AliasSystem(
D=[
Alias(
position_type,
name="position_type",
mapping={
"mapcoords": "g",
"boxcoords": "n",
"plotcoords": "x",
"inside": "j",
"outside": "J",
},
),
Alias(position, name="position", sep="/", size=2),
Alias(length, name="length", prefix="+w"),
Alias(justify, name="justify", prefix="+j"),
Alias(anchor_offset, name="anchor_offset", prefix="+o", sep="/", size=2),
Alias(
label_position,
name="label_position",
prefix="+a",
mapping={"left": "l", "right": "r"},
),
Alias(unit, name="unit", prefix="+l"),
],
J=Alias(projection, name="projection"),
).merge(kwargs)

Expand Down
Loading