55from collections .abc import Sequence
66from typing import Literal
77
8+ from pygmt ._typing import AnchorCode
89from pygmt .alias import Alias , AliasSystem
910from pygmt .clib import Session
10- from pygmt .helpers import build_arg_list , fmt_docstring , use_alias
11- from pygmt .params import Box
11+ from pygmt .exceptions import GMTInvalidInput
12+ from pygmt .helpers import build_arg_list , fmt_docstring
13+ from pygmt .params import Box , Position
14+ from pygmt .src ._common import _parse_position
1215
1316
1417@fmt_docstring
15- @use_alias (D = "position" )
16- def logo (
18+ def logo ( # noqa: PLR0913
1719 self ,
20+ position : Position | Sequence [float | str ] | AnchorCode | None = None ,
21+ width : float | str | None = None ,
22+ height : float | str | None = None ,
23+ box : Box | bool = False ,
24+ style : Literal ["standard" , "url" , "no_label" ] = "standard" ,
1825 projection : str | None = None ,
1926 region : Sequence [float | str ] | str | None = None ,
20- style : Literal ["standard" , "url" , "no_label" ] = "standard" ,
21- box : Box | bool = False ,
2227 verbose : Literal ["quiet" , "error" , "warning" , "timing" , "info" , "compat" , "debug" ]
2328 | bool = False ,
2429 panel : int | Sequence [int ] | bool = False ,
25- transparency : float | None = None ,
2630 perspective : float | Sequence [float ] | str | bool = False ,
31+ transparency : float | None = None ,
2732 ** kwargs ,
2833):
29- r """
34+ """
3035 Plot the GMT logo.
3136
32- By default, the GMT logo is 2 inches wide and 1 inch high and
33- will be positioned relative to the current plot origin.
34- Use various options to change this and to place a transparent or
35- opaque rectangular map panel behind the GMT logo.
37+ .. figure:: https://docs.generic-mapping-tools.org/6.6/_images/GMT_coverlogo.png
38+ :alt: GMT logo
39+ :align: center
40+ :width: 300px
41+
42+ By default, the GMT logo is 2 inches wide and 1 inch high and will be positioned
43+ relative to the current plot origin.
3644
3745 Full GMT docs at :gmt-docs:`gmtlogo.html`.
3846
39- $aliases
47+ **Aliases:**
48+
49+ .. hlist::
50+ :columns: 3
51+
52+ - D = position, **+w**: width, **+h**: height
4053 - F = box
4154 - J = projection
4255 - R = region
@@ -48,12 +61,22 @@ def logo(
4861
4962 Parameters
5063 ----------
51- $projection
52- $region
53- position : str
54- [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\
55- **+w**\ *width*\ [**+j**\ *justify*]\ [**+o**\ *dx*\ [/*dy*]].
56- Set reference point on the map for the image.
64+ position
65+ Position of the GMT logo on the plot. It can be specified in multiple ways:
66+
67+ - A :class:`pygmt.params.Position` object to fully control the reference point,
68+ anchor point, and offset.
69+ - A sequence of two values representing the x and y coordinates in plot
70+ coordinates, e.g., ``(1, 2)`` or ``("1c", "2c")``.
71+ - A :doc:`2-character justification code </techref/justification_codes>` for a
72+ position inside the plot, e.g., ``"TL"`` for Top Left corner inside the plot.
73+
74+ If not specified, defaults to the lower-left corner of the plot (position
75+ ``(0, 0)`` with anchor ``"BL"``).
76+ width
77+ height
78+ Width or height of the GMT logo. Since the aspect ratio is fixed, only one of
79+ the two can be specified. [Default is 2 inches wide and 1 inch high].
5780 box
5881 Draw a background box behind the logo. If set to ``True``, a simple rectangular
5982 box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box appearance,
@@ -65,14 +88,32 @@ def logo(
6588 - ``"standard"``: The text label "The Generic Mapping Tools".
6689 - ``"no_label"``: Skip the text label.
6790 - ``"url"``: The URL to the GMT website.
91+ $projection
92+ $region
6893 $verbose
6994 $panel
70- $transparency
7195 $perspective
96+ $transparency
7297 """
7398 self ._activate_figure ()
7499
100+ position = _parse_position (
101+ position ,
102+ kwdict = {"width" : width , "height" : height },
103+ default = Position ((0 , 0 ), cstype = "plotcoords" ), # Default to (0,0) in plotcoords
104+ )
105+
106+ # width and height are mutually exclusive.
107+ if width is not None and height is not None :
108+ msg = "Cannot specify both 'width' and 'height'."
109+ raise GMTInvalidInput (msg )
110+
75111 aliasdict = AliasSystem (
112+ D = [
113+ Alias (position , name = "position" ),
114+ Alias (height , name = "height" , prefix = "+h" ),
115+ Alias (width , name = "width" , prefix = "+w" ),
116+ ],
76117 F = Alias (box , name = "box" ),
77118 S = Alias (
78119 style , name = "style" , mapping = {"standard" : "l" , "url" : "u" , "no_label" : "n" }
0 commit comments