-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathlogo.py
More file actions
124 lines (108 loc) · 3.66 KB
/
logo.py
File metadata and controls
124 lines (108 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""
logo - Plot the GMT logo.
"""
from collections.abc import Sequence
from typing import Literal
from pygmt.alias import Alias, AliasSystem
from pygmt.clib import Session
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import build_arg_list, fmt_docstring
from pygmt.params import Box, Position
@fmt_docstring
def logo( # noqa: PLR0913
self,
position: Position | None = None,
width: float | str | None = None,
height: float | str | None = None,
box: Box | bool = False,
style: Literal["standard", "url", "no_label"] = "standard",
projection: str | None = None,
region: Sequence[float | str] | str | None = None,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
panel: int | Sequence[int] | bool = False,
transparency: float | None = None,
perspective: float | Sequence[float] | str | bool = False,
**kwargs,
):
"""
Plot the GMT logo.
.. figure:: https://docs.generic-mapping-tools.org/6.6/_images/GMT_coverlogo.png
:alt: GMT logo
:align: center
:width: 300px
By default, the GMT logo is 2 inches wide and 1 inch high and will be positioned
relative to the current plot origin.
Full GMT docs at :gmt-docs:`gmtlogo.html`.
**Aliases:**
.. hlist::
:columns: 3
- D = position, **+w**: width, **+h**: height
- F = box
- J = projection
- R = region
- S = style
- V = verbose
- c = panel
- p = perspective
- t = transparency
Parameters
----------
position
Specify the position of the GMT logo. See :class:`pygmt.params.Position` for
details.
width
height
Width or height of the GMT logo. Since the aspect ratio is fixed, only one of
the two can be specified.
box
Draw a background box behind the logo. If set to ``True``, a simple rectangular
box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box appearance,
pass a :class:`pygmt.params.Box` object to control style, fill, pen, and other
box properties.
style
Control what is written beneath the map portion of the logo.
- ``"standard"``: The text label "The Generic Mapping Tools".
- ``"no_label"``: Skip the text label.
- ``"url"``: The URL to the GMT website.
$projection
$region
$verbose
$panel
$transparency
$perspective
"""
self._activate_figure()
# Prior PyGMT v0.17.0, 'position' can accept a raw GMT CLI string. Check for
# conflicts with other parameters.
if isinstance(position, str) and any(v is not None for v in (width, height)):
msg = (
"Parameter 'position' is given with a raw GMT command string, and conflicts "
"with parameters 'width' and 'height'."
)
raise GMTInvalidInput(msg)
# width and height are mutually exclusive.
if width is not None and height is not None:
msg = "Cannot specify both 'width' and 'height'."
raise GMTInvalidInput(msg)
aliasdict = AliasSystem(
D=[
Alias(position, name="position"),
Alias(height, name="height", prefix="+h"),
Alias(width, name="width", prefix="+w"),
],
F=Alias(box, name="box"),
S=Alias(
style, name="style", mapping={"standard": "l", "url": "u", "no_label": "n"}
),
).add_common(
J=projection,
R=region,
V=verbose,
c=panel,
p=perspective,
t=transparency,
)
aliasdict.merge(kwargs)
with Session() as lib:
lib.call_module(module="logo", args=build_arg_list(aliasdict))