Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
88f381a
Allow adjust font
seisman May 7, 2026
6abbcfd
Merge branch 'pygmtlogo' into pygmtlogo-font
seisman May 9, 2026
5693140
Merge branch 'pygmtlogo' into pygmtlogo-font
seisman May 12, 2026
7b9f053
Revert "Allow adjust font"
seisman May 12, 2026
6cdbc34
Figure.pygmtlogo: Accurate positioning of the horizontal wordmark
seisman May 13, 2026
a8330fd
Add debugging lines for horizontal wordmark
seisman May 13, 2026
f03bd50
Smaller region for horizontal wordmark
seisman May 13, 2026
479cb58
Update the baseline image for horizontal wordmark design
seisman May 13, 2026
3f9affe
Reorder variables
seisman May 13, 2026
be6c052
Add a test and baseline image for circular logo with horizontal wordmark
seisman May 13, 2026
0bad58f
Merge branch 'pygmtlogo' into pygmtlogo-font
seisman May 13, 2026
6988c0f
Update baseline images
seisman May 14, 2026
f6d08a0
Simplify the test script
seisman May 14, 2026
3fdfb56
Figure.pygmtlogo: Parameterize existing tests
seisman May 14, 2026
b29bdc9
Remove two dvc files
seisman May 14, 2026
b4e1e38
Rename test_pygmtlogo_no_wordmark to test_pygmtlogo_wordmark_none
seisman May 14, 2026
e5f0af1
Merge branch 'pygmtlogo-parameterize' into pygmtlogo-font
seisman May 14, 2026
089d334
Remove one unused dvc file
seisman May 14, 2026
645ec10
Fix a typo
seisman May 14, 2026
678dabe
Merge branch 'pygmtlogo' into pygmtlogo-font
seisman May 14, 2026
c8c8c88
Merge branch 'pygmtlogo' into pygmtlogo-font
seisman May 23, 2026
d1e37f3
Merge branch 'pygmtlogo' into pygmtlogo-font
seisman Jun 6, 2026
a02b2ad
Merge branch 'pygmtlogo' into pygmtlogo-font
seisman Jun 8, 2026
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
28 changes: 24 additions & 4 deletions pygmt/src/pygmtlogo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _create_logo( # noqa: PLR0915
size = 4
proj = "x1c"
region = {
"horizontal": [-size, size * 8.0, -size, size],
"horizontal": [-size, size * 7.0, -size, size],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am wondering if we can calculate the exact width of the wordmark "PyGMT" and by this the exact value of x_max for the logo with horizontal 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.

We can, but since the values in the region parameter do not affect the appearance of the logos, I don’t think it’s necessary to perform additional calculations that rely on more magic numbers.

"vertical": [-size, size, -size * 1.75, size],
"none": [-size, size, -size, size],
}[wordmark]
Expand Down Expand Up @@ -79,12 +79,27 @@ def _create_logo( # noqa: PLR0915
hex_factor = 1.1

# Define wordmark
# See https://github.com/GenericMappingTools/pygmt/pull/4627#issuecomment-4437317011
# for the rationale behind the magic values.
font = "AvantGarde-Book"
pheight = 0.739 # Height of letter "P"
plsb = 0.076 # Left side bearing of letter "P"
pstroke = 0.0735 # Stroke thickness of letter "P"

match wordmark:
case "vertical":
args_text_wm = {"x": 0, "y": -4.5, "justify": "CT", "font": f"2.4c,{font}"}
args_wordmark = {"x": 0, "y": -4.5, "justify": "CT", "font": f"2.4c,{font}"}
case "horizontal":
args_text_wm = {"x": 4.5, "y": 0.8, "justify": "LM", "font": f"8c,{font}"}
# The stroke width matches the outline thickness.
# The left edge of "P" is aligned at y=size * 1.25.
# Letters "PGMT" are placed vertically centered at y=0.
fontsize = thick_shape / pstroke
args_wordmark = {
"x": size * 1.25 - plsb * fontsize,
"y": -pheight / 2.0 * fontsize,
"justify": "BL",
"font": f"{fontsize}c,{font}",
}

def _letter_g_coords():
"""Coordinates for letter G."""
Expand Down Expand Up @@ -218,7 +233,7 @@ def _compass_lines():

# Add wordmark "PyGMT"
if wordmark != "none":
fig.text(text=f"@;{color_py};Py@;;@;{color_gmt};GMT@;;", **args_text_wm)
fig.text(text=f"@;{color_py};Py@;;@;{color_gmt};GMT@;;", **args_wordmark)

# Helpful for implementing the logo; not included in the logo
if debug:
Expand All @@ -237,6 +252,11 @@ def _compass_lines():
fig.hlines(y=[r4, r5], xmin=-size_s, xmax=size_s, pen=pen, perspective=True)
m_mid = (thick_gap + r4) / 2
fig.vlines(x=[r4, m_mid], ymin=-size_s, ymax=size_s, pen=pen, perspective=True)
# Lines for wordmark
if wordmark == "horizontal":
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)

if figname:
fig.savefig(fname=figname)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: 8924c7d80afcc92df4e77e6856b553a4
size: 336254
- md5: 44a9a200fbac4c868b69cb1c13e6dfc5
size: 320394
hash: md5
path: test_pygmtlogo_design_circle-horizontal.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
outs:
- md5: 9715eb13bec45201818d701970a529c8
size: 63949
hash: md5
path: test_pygmtlogo_wordmark_horizontal_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 @@ -49,3 +49,32 @@ def test_pygmtlogo_wordmark_none(shape):
shape=shape,
)
return fig


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