Skip to content

Commit bd24b5a

Browse files
Force the default logo size to 2-cm and rename test_pygmtlogo to test_pygmtlogo_circle_no_wordmark (#4617)
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
1 parent 4868c8a commit bd24b5a

4 files changed

Lines changed: 35 additions & 12 deletions

File tree

pygmt/src/pygmtlogo.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import numpy as np
1212
from pygmt._typing import AnchorCode, PathLike
13+
from pygmt.exceptions import GMTValueError
1314
from pygmt.helpers import GMTTempFile, fmt_docstring
1415
from pygmt.params import Box, Position
1516

@@ -304,7 +305,8 @@ def pygmtlogo( # noqa: PLR0913
304305
width
305306
height
306307
Width or height of the PyGMT logo. Since the aspect ratio is fixed, only one of
307-
the two can be specified.
308+
the two can be specified. If not specified, the default size of the visual logo
309+
is set to 2 cm.
308310
box
309311
Draw a background box behind the logo. If set to ``True``, a simple rectangular
310312
box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box appearance,
@@ -333,6 +335,20 @@ def pygmtlogo( # noqa: PLR0913
333335
>>> fig.pygmtlogo(wordmark="horizontal", position="BR", height="1c")
334336
>>> fig.show()
335337
"""
338+
# Set the default size of the visual logo to 2 cm.
339+
if width is None and height is None:
340+
match wordmark:
341+
case "none" | "vertical":
342+
width = width or "2c"
343+
case "horizontal":
344+
height = height or "2c"
345+
case _:
346+
raise GMTValueError(
347+
wordmark,
348+
description="value for wordmark",
349+
choices={"none", "horizontal", "vertical"},
350+
)
351+
336352
with GMTTempFile(suffix=".eps") as logofile:
337353
# Create logo file
338354
_create_logo(

pygmt/tests/baseline/test_pygmtlogo.png.dvc

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
outs:
2+
- md5: b1dee02932b292335cf5f8b95676a258
3+
size: 19161
4+
hash: md5
5+
path: test_pygmtlogo_circle_no_wordmark.png

pygmt/tests/test_pygmtlogo.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@
44

55
import pytest
66
from pygmt import Figure
7+
from pygmt.params import Axis, Position
78

89

9-
@pytest.mark.benchmark
1010
@pytest.mark.mpl_image_compare
11-
def test_pygmtlogo():
11+
def test_pygmtlogo_circle_no_wordmark():
1212
"""
13-
Plot the default PyGMT logo, colored, light and dark themes, without wordmark.
13+
Test the PyGMT circular logo without the wordmark, including both light/dark themes,
14+
and colored/black-and-white versions.
1415
"""
1516
fig = Figure()
16-
fig.pygmtlogo()
17-
fig.shift_origin(xshift="+w")
18-
fig.pygmtlogo(theme="dark")
17+
fig.basemap(region=[-0.5, 5.0, -0.5, 5.0], projection="x1c", frame=Axis(grid=0.5))
18+
fig.pygmtlogo(
19+
position=Position((1, 3.5), anchor="CM", cstype="mapcoords"),
20+
theme="light",
21+
)
22+
fig.pygmtlogo(
23+
position=Position((3.5, 3.5), anchor="CM", cstype="mapcoords"),
24+
theme="dark",
25+
)
1926
return fig

0 commit comments

Comments
 (0)