Skip to content
Merged
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
18 changes: 17 additions & 1 deletion pygmt/src/pygmtlogo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import numpy as np
from pygmt._typing import AnchorCode, PathLike
from pygmt.exceptions import GMTValueError
from pygmt.helpers import GMTTempFile, fmt_docstring
from pygmt.params import Box, Position

Expand Down Expand Up @@ -304,7 +305,8 @@ def pygmtlogo( # noqa: PLR0913
width
height
Width or height of the PyGMT logo. Since the aspect ratio is fixed, only one of
the two can be specified.
the two can be specified. If not specified, the default size of the visual logo
is set to 2 cm.
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 Down Expand Up @@ -333,6 +335,20 @@ def pygmtlogo( # noqa: PLR0913
>>> fig.pygmtlogo(wordmark="horizontal", position="BR", height="1c")
>>> fig.show()
"""
# Set the default size of the visual logo to 2 cm.
if width is None and height is None:
match wordmark:
case "none" | "vertical":
width = width or "2c"
case "horizontal":
height = height or "2c"
case _:
raise GMTValueError(
wordmark,
description="value for wordmark",
choices={"none", "horizontal", "vertical"},
)

with GMTTempFile(suffix=".eps") as logofile:
# Create logo file
_create_logo(
Expand Down
5 changes: 0 additions & 5 deletions pygmt/tests/baseline/test_pygmtlogo.png.dvc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
outs:
- md5: b1dee02932b292335cf5f8b95676a258
size: 19161
hash: md5
path: test_pygmtlogo_circle_no_wordmark.png
19 changes: 13 additions & 6 deletions pygmt/tests/test_pygmtlogo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@

import pytest
from pygmt import Figure
from pygmt.params import Axis, Position


@pytest.mark.benchmark
@pytest.mark.mpl_image_compare
def test_pygmtlogo():
def test_pygmtlogo_circle_no_wordmark():
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other tests will be named like

  • test_pygmtlogo_circle_horizontal_wordmark
  • test_pygmtlogo_circle_vertical_wordmark
  • test_pygmtlogo_hexagon_no_wordmark
  • test_pygmtlogo_hexagon_horizontal_wordmark
  • test_pygmtlogo_hexagon_vertical_wordmark

"""
Plot the default PyGMT logo, colored, light and dark themes, without wordmark.
Test the PyGMT circular logo without the wordmark, including both light/dark themes,
and colored/black-and-white versions.
"""
fig = Figure()
fig.pygmtlogo()
fig.shift_origin(xshift="+w")
fig.pygmtlogo(theme="dark")
fig.basemap(region=[-0.5, 5.0, -0.5, 5.0], projection="x1c", frame=Axis(grid=0.5))
fig.pygmtlogo(
position=Position((1, 3.5), anchor="CM", cstype="mapcoords"),
theme="light",
)
fig.pygmtlogo(
position=Position((3.5, 3.5), anchor="CM", cstype="mapcoords"),
theme="dark",
)
Copy link
Copy Markdown
Member Author

@seisman seisman May 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plan to add the two black-and-white logos below the colored versions in later PRs.

return fig
Loading