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
42 changes: 40 additions & 2 deletions pygmt/src/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
image - Plot raster or EPS images.
"""

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

from pygmt._typing import AnchorCode, PathLike
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 @@ -21,7 +24,21 @@
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def image(self, imagefile: PathLike, projection=None, **kwargs):
def image(
self,
imagefile: PathLike,
position: Sequence[float | str] | AnchorCode,
projection=None,
position_type: Literal[
"mapcoords", "boxcoords", "plotcoords", "inside", "outside"
] = "mapcoords",
width=None,
height=None,
replicate=None,
dpi=None,
anchor_offset=None,
**kwargs,
):
r"""
Plot raster or EPS images.

Expand Down Expand Up @@ -69,10 +86,31 @@ def image(self, imagefile: PathLike, projection=None, **kwargs):
{perspective}
{transparency}
"""

self._activate_figure()

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

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
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"),
Alias(replicate, name="replicate", prefix="+n", sep="/", size=2),
Alias(dpi, name="dpi", prefix="+r"),
Alias(anchor_offset, name="anchor_offset", prefix="+o", sep="/", size=2),
],
).merge(kwargs)

with Session() as lib:
Expand Down
Loading