Skip to content
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
32 changes: 31 additions & 1 deletion pygmt/src/inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from collections.abc import Sequence
from typing import Literal

from pygmt._typing import AnchorCode
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 All @@ -18,8 +19,16 @@
@contextlib.contextmanager
@use_alias(D="position", M="margin")
@kwargs_to_strings(D="sequence", M="sequence")
def inset(
def inset( # noqa: PLR0913
self,
position: Sequence[str | float] | AnchorCode,
position_type: Literal[
"mapcoords", "boxcoords", "plotcoords", "inside", "outside"
] = "mapcoords",
width: float | str | None = None,
height: float | str | None = None,
justify: AnchorCode | None = None,
anchor_offset: Sequence[float] | None = None,
projection: str | None = None,
region: Sequence[float | str] | str | None = None,
box: Box | bool = False,
Expand Down Expand Up @@ -133,7 +142,28 @@ def inset(
"""
self._activate_figure()

# -D[g|j|J|n|x]refpoint+wwidth[/height][+jjustify][+odx[/dy]]

_dimension = (width, height) if height is not None else width

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(_dimension, name="width/height", prefix="+w", sep="/", size=2),
Alias(justify, name="justify", prefix="+j"),
Alias(anchor_offset, name="anchor_offset", prefix="+o", sep="/", size=2),
],
F=Alias(box, name="box"),
N=Alias(no_clip, name="no_clip"),
).add_common(
Expand Down
Loading