diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 8da5e008f16..93286689cd7 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -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 @@ -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, @@ -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( diff --git a/pygmt/tests/baseline/test_pygmtlogo.png.dvc b/pygmt/tests/baseline/test_pygmtlogo.png.dvc deleted file mode 100644 index 010f8e4c4db..00000000000 --- a/pygmt/tests/baseline/test_pygmtlogo.png.dvc +++ /dev/null @@ -1,5 +0,0 @@ -outs: -- md5: 35c59c31c92f13c705a24933465ff551 - size: 14374 - hash: md5 - path: test_pygmtlogo.png diff --git a/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc b/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc new file mode 100644 index 00000000000..d33a5c5bd35 --- /dev/null +++ b/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc @@ -0,0 +1,5 @@ +outs: +- md5: b1dee02932b292335cf5f8b95676a258 + size: 19161 + hash: md5 + path: test_pygmtlogo_circle_no_wordmark.png diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index fb117b9b097..2495a9a3a1a 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -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(): """ - 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", + ) return fig