Skip to content
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pygmt/params/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

from pygmt.params.box import Box
from pygmt.params.pattern import Pattern
from pygmt.params.position import Position
42 changes: 42 additions & 0 deletions pygmt/params/position.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
The Position class for positioning GMT embellishments.
"""

import dataclasses
from collections.abc import Sequence
from typing import Literal

from pygmt._typing import AnchorCode
from pygmt.alias import Alias
from pygmt.params.base import BaseParam


@dataclasses.dataclass(repr=False)
class Position(BaseParam):
"""
The class for positioning GMT embellishments.
"""

location: str | tuple[float | str, float | str]
type: Literal["mapcoords", "inside", "outside", "boxcoords", "plotcoords"]
anchor: AnchorCode
offset: Sequence[float | str]

@property
def _aliases(self):
return [
Alias(
self.type,
name="type",
mapping={
"mapcoords": "g",
"boxcoords": "n",
"plotcoords": "x",
"inside": "j",
"outside": "J",
},
),
Alias(self.location, name="location", sep="/", size=2),
Alias(self.anchor, name="anchor"),
Alias(self.offset, name="offset", sep="/", size=2),
]
22 changes: 17 additions & 5 deletions pygmt/src/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

from pygmt.alias import Alias, AliasSystem
from pygmt.clib import Session
from pygmt.helpers import build_arg_list, fmt_docstring, use_alias
from pygmt.params import Box
from pygmt.helpers import build_arg_list, fmt_docstring
from pygmt.params import Box, Position


@fmt_docstring
@use_alias(D="position")
def logo(
def logo( # noqa: PLR0913
self,
position: Position,
width: float | str | None = None,
height: float | str | None = None,
projection: str | None = None,
region: Sequence[float | str] | str | None = None,
style: Literal["standard", "url", "no_label"] = "standard",
Expand All @@ -36,7 +38,12 @@ def logo(

Full GMT docs at :gmt-docs:`gmtlogo.html`.

{aliases}
**Aliases:**

.. hlist::
:columns: 3

- D = position, **+w**: width, **+h**: height
- F = box
- J = projection
- R = region
Expand Down Expand Up @@ -73,6 +80,11 @@ def logo(
self._activate_figure()

aliasdict = AliasSystem(
D=[
Alias(position, name="position"),
Alias(width, name="width", prefix="+w"),
Alias(height, name="height", prefix="+h"),
],
F=Alias(box, name="box"),
S=Alias(
style, name="style", mapping={"standard": "l", "url": "u", "no_label": "n"}
Expand Down
Loading