Skip to content
13 changes: 12 additions & 1 deletion pygmt/src/pygmtlogo.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,19 @@ def _create_logo( # noqa: PLR0915
pheight = 0.739 # Height of letter "P"
plsb = 0.076 # Left side bearing of letter "P"
pstroke = 0.0735 # Stroke thickness of letter "P"
pygmtwidth = 3.262 # Full width of "PyGMT"

match wordmark:
case "vertical":
args_wordmark = {"x": 0, "y": -4.5, "justify": "CT", "font": f"2.4c,{font}"}
# Ensure the same width for the visual logo and wordmark
fontsize = size * 2.0 / pygmtwidth
args_wordmark = {
"x": -size - fontsize * plsb,
"y": -size * 1.125,
"justify": "TL",
"font": f"{fontsize}c,{font}",
"no_clip": True, # Needed because x<xmin.
}
case "horizontal":
# The stroke width matches the outline thickness.
# The left edge of "P" is aligned at y=size * 1.25.
Expand Down Expand Up @@ -257,6 +266,8 @@ def _compass_lines():
halfheight = pheight / 2.0 * fontsize
fig.hlines(y=[-halfheight, halfheight], xmin=size, pen=pen)
fig.vlines(x=[size * 1.25, size * 1.25 + pstroke * fontsize], pen=pen)
elif wordmark == "vertical":
fig.hlines(y=-size * 1.125, pen=pen)

if figname:
fig.savefig(fname=figname)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: 5ee82660f20bc8424f3051af4f9fb9ac
size: 173671
- md5: affb1d00551312eaaf132e8566dd446b
size: 174450
hash: md5
path: test_pygmtlogo_design_circle-vertical.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
outs:
- md5: 666643ce5d01dafd5d1831a511c12812
size: 40928
hash: md5
path: test_pygmtlogo_wordmark_vertical_circle.png
29 changes: 29 additions & 0 deletions pygmt/tests/test_pygmtlogo.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,32 @@ def test_pygmtlogo_wordmark_horizontal(shape):
wordmark="horizontal",
)
return fig


@pytest.mark.mpl_image_compare
@pytest.mark.parametrize("shape", ["circle"])
def test_pygmtlogo_wordmark_vertical(shape):
"""
Test the PyGMT logo with a vertical wordmark, including both light/dark themes,
and colored/black-and-white versions.
"""
fig = Figure()
fig.basemap(
region=[-0.5, 5.0, -0.5, 5.5],
projection="x1c",
frame=Frame(fill="gray", axis=Axis(grid=0.5)),
)
for (x, y), theme, color in [
((1.0, 4.0), "light", True),
((3.5, 4.0), "dark", True),
((1.0, 1.0), "light", False),
((3.5, 1.0), "dark", False),
]:
fig.pygmtlogo(
position=Position((x, y), anchor="CM", cstype="mapcoords"),
theme=theme,
color=color,
shape=shape,
wordmark="vertical",
)
return fig
Loading