From ca78f8b4c144c2b2159d6689386fa3d59caa0ad2 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 2 May 2026 20:50:28 +0800 Subject: [PATCH 1/7] Rename test_pygmtlogo function to test_pygmtlogo_circle_no_wordmark and improve it --- pygmt/tests/baseline/test_pygmtlogo.png.dvc | 5 ----- .../test_pygmtlogo_circle_no_wordmark.png.dvc | 5 +++++ pygmt/tests/test_pygmtlogo.py | 16 +++++++++++----- 3 files changed, 16 insertions(+), 10 deletions(-) delete mode 100644 pygmt/tests/baseline/test_pygmtlogo.png.dvc create mode 100644 pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc 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..147ec9f94cb --- /dev/null +++ b/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc @@ -0,0 +1,5 @@ +outs: +- md5: f71418c9c7566665086b6b250cc564c4 + size: 18618 + 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..60e61cdee8d 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -4,16 +4,22 @@ 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. """ 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 From de990ccda7d6d69a73b9d482a198dfd491e4bee6 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 2 May 2026 21:33:21 +0800 Subject: [PATCH 2/7] Improve docstring for test --- pygmt/tests/test_pygmtlogo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index 60e61cdee8d..2495a9a3a1a 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -10,7 +10,8 @@ @pytest.mark.mpl_image_compare 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.basemap(region=[-0.5, 5.0, -0.5, 5.0], projection="x1c", frame=Axis(grid=0.5)) From ecb0ba747767ec4338465da113e08e23749793ba Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 5 May 2026 00:14:41 +0800 Subject: [PATCH 3/7] Change size so that the default logo width is 2 cm --- pygmt/src/pygmtlogo.py | 2 +- .../tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 8da5e008f16..846c6f29068 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -30,7 +30,7 @@ def _create_logo( # noqa: PLR0915 from pygmt.figure import Figure # noqa: PLC0415 # Helpful definitions - size = 4 + size = 4.1615 # size to make the circular logo 2-cm wide when plotted with 300 dpi. region = [-size, size] * 2 proj = "x1c" # Rotation around z-axis by 30 degrees counter-clockwise placed in the center. diff --git a/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc b/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc index 147ec9f94cb..53388bc4820 100644 --- a/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc +++ b/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc @@ -1,5 +1,5 @@ outs: -- md5: f71418c9c7566665086b6b250cc564c4 - size: 18618 +- md5: f51201395f10bc1abce47b44a35b409e + size: 19234 hash: md5 path: test_pygmtlogo_circle_no_wordmark.png From 8ad8a01cf47cfdc456899806199a6e9199ae4e57 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 6 May 2026 01:37:30 +0800 Subject: [PATCH 4/7] Update pygmt/src/pygmtlogo.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 846c6f29068..e60c2e5e5ce 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -30,6 +30,7 @@ def _create_logo( # noqa: PLR0915 from pygmt.figure import Figure # noqa: PLC0415 # Helpful definitions + # See https://github.com/GenericMappingTools/pygmt/pull/4617#issuecomment-4366140123 size = 4.1615 # size to make the circular logo 2-cm wide when plotted with 300 dpi. region = [-size, size] * 2 proj = "x1c" From 042653fe7d0a42fa3020df2a4b9b633096b40ad0 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 6 May 2026 11:06:02 +0800 Subject: [PATCH 5/7] Revert "Update pygmt/src/pygmtlogo.py" This reverts commit 8ad8a01cf47cfdc456899806199a6e9199ae4e57. --- pygmt/src/pygmtlogo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e60c2e5e5ce..846c6f29068 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -30,7 +30,6 @@ def _create_logo( # noqa: PLR0915 from pygmt.figure import Figure # noqa: PLC0415 # Helpful definitions - # See https://github.com/GenericMappingTools/pygmt/pull/4617#issuecomment-4366140123 size = 4.1615 # size to make the circular logo 2-cm wide when plotted with 300 dpi. region = [-size, size] * 2 proj = "x1c" From 2ce4d9363a2ce94510877c8cd4a1817628f3a7d5 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 6 May 2026 11:06:20 +0800 Subject: [PATCH 6/7] Revert "Change size so that the default logo width is 2 cm" This reverts commit ecb0ba747767ec4338465da113e08e23749793ba. --- pygmt/src/pygmtlogo.py | 2 +- .../tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 846c6f29068..8da5e008f16 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -30,7 +30,7 @@ def _create_logo( # noqa: PLR0915 from pygmt.figure import Figure # noqa: PLC0415 # Helpful definitions - size = 4.1615 # size to make the circular logo 2-cm wide when plotted with 300 dpi. + size = 4 region = [-size, size] * 2 proj = "x1c" # Rotation around z-axis by 30 degrees counter-clockwise placed in the center. diff --git a/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc b/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc index 53388bc4820..147ec9f94cb 100644 --- a/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc +++ b/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc @@ -1,5 +1,5 @@ outs: -- md5: f51201395f10bc1abce47b44a35b409e - size: 19234 +- md5: f71418c9c7566665086b6b250cc564c4 + size: 18618 hash: md5 path: test_pygmtlogo_circle_no_wordmark.png From aafb290eeddf115618b69cd510273b0544fc146d Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 6 May 2026 11:17:08 +0800 Subject: [PATCH 7/7] Set default logo size to 2-cm if not set --- pygmt/src/pygmtlogo.py | 18 +++++++++++++++++- .../test_pygmtlogo_circle_no_wordmark.png.dvc | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) 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_circle_no_wordmark.png.dvc b/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc index 147ec9f94cb..d33a5c5bd35 100644 --- a/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc +++ b/pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png.dvc @@ -1,5 +1,5 @@ outs: -- md5: f71418c9c7566665086b6b250cc564c4 - size: 18618 +- md5: b1dee02932b292335cf5f8b95676a258 + size: 19161 hash: md5 path: test_pygmtlogo_circle_no_wordmark.png