Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
fb64cbf
Figure.logo: Refactor using the AliasSystem class
seisman Jul 26, 2025
1eb6587
Update position_type
seisman Aug 10, 2025
6fa17ac
Updates
seisman Aug 10, 2025
cb40511
Merge branch 'main' into refactor/logo
seisman Sep 3, 2025
6edab47
Merge branch 'main' into refactor/logo
seisman Sep 4, 2025
cd1165f
fix
seisman Sep 9, 2025
dab0bdb
Merge branch 'main' into refactor/logo
seisman Sep 9, 2025
494afc5
Merge branch 'main' into refactor/logo
seisman Sep 9, 2025
b17ecfe
Remove D from use_alias
seisman Sep 9, 2025
6ec9c66
Fix typos
seisman Sep 9, 2025
9307150
Merge branch 'main' into refactor/logo
seisman Sep 11, 2025
9a0575d
Improve docstrings
seisman Sep 11, 2025
d19959e
Improve docstrings
seisman Sep 12, 2025
df0aba0
Merge branch 'main' into refactor/logo
seisman Sep 12, 2025
f8f418b
Backward compatibility
seisman Sep 14, 2025
df50342
Improve Figure.logo tests
seisman Sep 15, 2025
6bd1dc2
Merge branch 'main' into refactor/logo
seisman Sep 15, 2025
8699d9a
Add a test for mixed syntax
seisman Sep 15, 2025
2f09ee9
Merge branch 'main' into refactor/logo
seisman Sep 18, 2025
da38bd1
Merge branch 'main' into refactor/logo
seisman Oct 15, 2025
5e02d22
Update docstrings
seisman Oct 15, 2025
7568264
Fix formatting
seisman Oct 15, 2025
43d08a0
Fix docstrings
seisman Oct 15, 2025
91b6b25
Fix long docstrings
seisman Oct 15, 2025
4f61e2e
Merge branch 'main' into refactor/logo
seisman Oct 16, 2025
6d3dc9b
Fix docstrings
seisman Oct 16, 2025
62e6274
Fix docstrings
seisman Oct 16, 2025
e3d14d5
Fix docstrings
seisman Oct 16, 2025
e73dc9e
Fix comments
seisman Oct 16, 2025
e77993b
Fix docstrings
seisman Oct 16, 2025
66f9c4d
Fix docstrings
seisman Oct 16, 2025
a33bf5d
Merge branch 'main' into refactor/logo
seisman Oct 18, 2025
fb95478
Fix offset to anchor_offset in the Figure.inset doctest
seisman Oct 18, 2025
9ca90fb
Merge remote-tracking branch 'origin/refactor/logo' into refactor/logo
seisman Oct 18, 2025
51fe976
Improve the handling of deprecation position parameter
seisman Oct 21, 2025
71bc7cc
Merge branch 'main' into refactor/logo
seisman Nov 7, 2025
f22afc1
Merge branch 'main' into refactor/logo
seisman Nov 9, 2025
5027a41
Merge branch 'main' into refactor/logo
seisman Nov 12, 2025
573e950
Fix docstrings in tests
seisman Nov 12, 2025
173e7a4
Shorten the docstrings
seisman Nov 12, 2025
92d8b08
Merge branch 'main' into refactor/logo
seisman Nov 15, 2025
eec0fb7
Initial implemention of the Position class
seisman Nov 16, 2025
69d4d42
Merge branch 'main' into params/position
seisman Nov 20, 2025
539f66f
Fix styling
seisman Nov 20, 2025
97f015f
Add tests and improve docstrings
seisman Nov 23, 2025
854804e
Add to API doc
seisman Nov 23, 2025
6b55dde
Add an inline doctest
seisman Nov 23, 2025
3d629cb
position is not required
seisman Nov 23, 2025
576b822
Default to plotcoords
seisman Nov 23, 2025
f54bec9
Updates
seisman Nov 23, 2025
5a2e20b
Merge branch 'main' into params/position
seisman Nov 24, 2025
2c59b7f
Improve the checking in Figure.logo
seisman Nov 24, 2025
d0b62ec
Merge branch 'main' into params/position
seisman Nov 24, 2025
fe18c87
Improve docstrings
seisman Nov 24, 2025
038161b
Improve docstrings
seisman Nov 24, 2025
a6e75bc
Improve docstrings
seisman Nov 25, 2025
3ec8c06
Improve docstrings
seisman Nov 25, 2025
339ce00
Improve docstrings
seisman Nov 25, 2025
4d616de
Revert changes in logo.py
seisman Nov 25, 2025
ad9e0aa
Simplify tests
seisman Nov 25, 2025
b084e5f
Validate values
seisman Nov 25, 2025
d4ad6e0
type will be validated in the Alias System
seisman Nov 25, 2025
7dc37bd
Use the image from the GMT docs
seisman Nov 25, 2025
bfecb2d
Fix width and alignment
seisman Nov 25, 2025
f49d4db
Merge branch 'params/position' into refactor/logo
seisman Nov 25, 2025
9f2cafd
Refactor Figure.logo using the Position class
seisman Nov 25, 2025
026e583
Remove some tests
seisman Nov 25, 2025
e9dd1e0
Update examples/gallery/embellishments/gmt_logo.py
seisman Nov 25, 2025
18b90b3
Improve docstrings
seisman Nov 25, 2025
6b1b5bc
Remove unneeded blank lines
seisman Nov 25, 2025
1eae742
Improve docstrings
seisman Nov 25, 2025
721b46f
Validate anchor code
seisman Nov 25, 2025
669b16d
Merge branch 'main' into params/position
seisman Nov 26, 2025
2a38111
Merge branch 'main' into params/position
seisman Nov 26, 2025
0f9ed6c
offset can be a single value
seisman Nov 26, 2025
7d1b076
Merge branch 'main' into params/position
seisman Nov 29, 2025
a779431
Merge branch 'main' into params/position
seisman Dec 1, 2025
2a9cc92
Merge branch 'main' into params/position
seisman Dec 4, 2025
10a0dfb
Use is_nonstr_iter to check the location parameter
seisman Dec 4, 2025
6f1c2c4
Merge remote-tracking branch 'origin/params/position' into params/pos…
seisman Dec 4, 2025
c27213f
Fix a typo [skip ci]
seisman Dec 4, 2025
d47aaeb
Fix a typo [skip ci]
seisman Dec 4, 2025
7fc6ffc
Fix the wrong logic in checking location
seisman Dec 4, 2025
d82f4ba
Add a tests for passing a single value to offset
seisman Dec 4, 2025
5d29e66
Merge branch 'main' into params/position
seisman Dec 5, 2025
563b5a1
Merge branch 'main' into params/position
seisman Dec 5, 2025
02d8713
Add the Axes, Axis, Frame classes for the frame parameter
seisman Jul 26, 2025
6f97c57
Add to API documentation
seisman Nov 15, 2025
b2c9877
Improve Axis/Axes/Frame and add more tests
seisman Dec 5, 2025
0ec021b
Merge branch 'main' into params/position
seisman Dec 6, 2025
42dede8
Merge branch 'AliasSystem/params/frame' into refactor/logo
seisman Dec 6, 2025
708eeac
Revert "Improve Axis/Axes/Frame and add more tests"
seisman Dec 6, 2025
e30969e
Revert "Add to API documentation"
seisman Dec 6, 2025
353a73d
Revert "Add the Axes, Axis, Frame classes for the frame parameter"
seisman Dec 6, 2025
f254da2
Merge remote-tracking branch 'origin/params/position' into refactor/logo
seisman Dec 6, 2025
238eb2e
Fix an inline doctest
seisman Dec 6, 2025
d2ed7b7
Improve the import in examples/gallery/embellishments/gmt_logo.py
seisman Dec 6, 2025
9e9c0d6
Fix the inline doctest in inset
seisman Dec 6, 2025
271af68
Reorder parameters
seisman Dec 6, 2025
ff23ac8
Merge branch 'main' into params/position
seisman Dec 6, 2025
c9c4222
Rename position to refpoint
seisman Dec 7, 2025
0064cde
Fix formatting
seisman Dec 7, 2025
bd223e2
Use any() to simplify codes
seisman Dec 7, 2025
97a13f1
Improve error message
seisman Dec 7, 2025
90c7ea2
Merge branch 'main' into params/position
seisman Dec 8, 2025
91b5630
r-string is not required
seisman Dec 8, 2025
9a19c1a
Merge branch 'main' into params/position
seisman Dec 8, 2025
ff6392d
Update pygmt/params/position.py
seisman Dec 9, 2025
2310b22
Update pygmt/params/position.py [skip ci]
seisman Dec 9, 2025
a3185e8
Fix styling
seisman Dec 9, 2025
e153ebf
Rename type to cstype
seisman Dec 9, 2025
ed31e0f
Merge branch 'main' into params/position
seisman Dec 9, 2025
fe5c47a
Fix type to cstype
seisman Dec 9, 2025
8e75634
Merge branch 'params/position' into refactor/logo
seisman Dec 9, 2025
eaa0a50
Merge branch 'main' into refactor/logo
seisman Dec 11, 2025
3a48d4d
cstype="inside" is the default
seisman Dec 11, 2025
f50921b
Merge branch 'main' into refactor/logo
seisman Dec 12, 2025
066e471
Merge branch 'main' into refactor/logo
seisman Dec 12, 2025
a69b6ea
Merge branch 'main' into refactor/logo
seisman Dec 13, 2025
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
4 changes: 2 additions & 2 deletions examples/gallery/embellishments/gmt_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

# %%
import pygmt
from pygmt.params import Position

fig = pygmt.Figure()
fig.basemap(region=[0, 10, 0, 2], projection="X6c", frame=True)

# Add the GMT logo in the Top Right (TR) corner of the current plot, scaled up to be 3
# centimeters wide and offset by 0.3 cm in x-direction and 0.6 cm in y-direction.
fig.logo(position="jTR+o0.3c/0.6c+w3c")

fig.logo(position=Position("TR", offset=(0.3, 0.6)), width="3c")
fig.show()
7 changes: 3 additions & 4 deletions pygmt/src/inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def inset(
Examples
--------
>>> import pygmt
>>> from pygmt.params import Box
>>> from pygmt.params import Box, Position
>>>
>>> # Create the larger figure
>>> fig = pygmt.Figure()
Expand All @@ -126,9 +126,8 @@ def inset(
... dcw="MG+gred",
... )
...
>>> # Map elements outside the "with" statement are plotted in the main
>>> # figure
>>> fig.logo(position="jBR+o0.2c+w3c")
>>> # Map elements outside the "with" statement are plotted in the main figure
>>> fig.logo(position=Position("BR", offset=0.2), width="3c")
>>> fig.show()
"""
self._activate_figure()
Expand Down
69 changes: 51 additions & 18 deletions pygmt/src/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,47 @@

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.exceptions import GMTInvalidInput
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 | 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,
style: Literal["standard", "url", "no_label"] = "standard",
box: Box | bool = False,
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,
):
r"""
"""
Plot the GMT logo.

By default, the GMT logo is 2 inches wide and 1 inch high and
will be positioned relative to the current plot origin.
Use various options to change this and to place a transparent or
opaque rectangular map panel behind 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
**Aliases:**

.. hlist::
:columns: 3

- D = position, **+w**: width, **+h**: height
- F = box
- J = projection
- R = region
Expand All @@ -48,12 +59,13 @@ def logo(

Parameters
----------
$projection
$region
position : str
[**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\
**+w**\ *width*\ [**+j**\ *justify*]\ [**+o**\ *dx*\ [/*dy*]].
Set reference point on the map for the image.
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,
Expand All @@ -65,14 +77,35 @@ def 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"}
Expand Down
35 changes: 34 additions & 1 deletion pygmt/tests/test_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pytest
from pygmt import Figure
from pygmt.exceptions import GMTInvalidInput
from pygmt.params import Position


@pytest.mark.benchmark
Expand All @@ -24,5 +26,36 @@ def test_logo_on_a_map():
"""
fig = Figure()
fig.basemap(region=[-90, -70, 0, 20], projection="M15c", frame=True)
fig.logo(position="jTR+o0.25c/0.25c+w7.5c", box=True)
fig.logo(position=Position("TR", offset=(0.25, 0.25)), width="7.5c", box=True)
return fig


@pytest.mark.mpl_image_compare(filename="test_logo_on_a_map.png")
def test_logo_position_deprecated_syntax():
"""
Test that passing the deprecated GMT CLI syntax string to 'position' works.
"""
fig = Figure()
fig.basemap(region=[-90, -70, 0, 20], projection="M15c", frame=True)
fig.logo(position="jTR+o0.25/0.25+w7.5c", box=True)
return fig


def test_logo_width_and_height():
"""
Test that an error is raised when both width and height are specified.
"""
fig = Figure()
with pytest.raises(GMTInvalidInput):
fig.logo(width="5c", height="5c")


def test_logo_position_mixed_syntax():
"""
Test that an error is raised when mixing new and deprecated syntax in 'position'.
"""
fig = Figure()
with pytest.raises(GMTInvalidInput):
fig.logo(position="jTL", width="5c")
with pytest.raises(GMTInvalidInput):
fig.logo(position="jTL", height="6c")