Skip to content

Commit 71f66dd

Browse files
Figure.pygmtlogo: Set the region based on wordmark for easier design (#4634)
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
1 parent 5c7d482 commit 71f66dd

5 files changed

Lines changed: 26 additions & 14 deletions

pygmt/src/pygmtlogo.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ def _create_logo( # noqa: PLR0915
3232

3333
# Helpful definitions
3434
size = 4
35-
region = [-size, size] * 2
3635
proj = "x1c"
36+
region = {
37+
"horizontal": [-size, size * 8.0, -size, size],
38+
"vertical": [-size, size, -size * 1.75, size],
39+
"none": [-size, size, -size, size],
40+
}[wordmark]
41+
3742
# Rotation around z-axis by 30 degrees counter-clockwise placed in the center.
3843
perspective = "30+w0/0"
3944

@@ -77,7 +82,7 @@ def _create_logo( # noqa: PLR0915
7782
font = "AvantGarde-Book"
7883
match wordmark:
7984
case "vertical":
80-
args_text_wm = {"x": 0, "y": -4.5, "justify": "CT", "font": f"2.5c,{font}"}
85+
args_text_wm = {"x": 0, "y": -4.5, "justify": "CT", "font": f"2.4c,{font}"}
8186
case "horizontal":
8287
args_text_wm = {"x": 4.5, "y": 0.8, "justify": "LM", "font": f"8c,{font}"}
8388

@@ -224,8 +229,7 @@ def _compass_lines():
224229

225230
# Add wordmark "PyGMT"
226231
if wordmark != "none":
227-
text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;"
228-
fig.text(text=text_wm, no_clip=True, **args_text_wm)
232+
fig.text(text=f"@;{color_py};Py@;;@;{color_gmt};GMT@;;", **args_text_wm)
229233

230234
# Helpful for implementing the logo; not included in the logo
231235
if debug:
@@ -240,8 +244,10 @@ def _compass_lines():
240244
pen = "0.3p,gray30,2_2"
241245
fig.plot(x=0, y=0, style=f"c{2 * (r2 + (r3 - r4))}c", pen=pen)
242246
# Lines for letter M
243-
fig.hlines(y=[r4, r5], xmin=-3, pen=pen, perspective=True)
244-
fig.vlines(x=[r4, (thick_gap + r4) / 2], ymax=3, pen=pen, perspective=True)
247+
size_s = 0.9 * size
248+
fig.hlines(y=[r4, r5], xmin=-size_s, xmax=size_s, pen=pen, perspective=True)
249+
m_mid = (thick_gap + r4) / 2
250+
fig.vlines(x=[r4, m_mid], ymin=-size_s, ymax=size_s, pen=pen, perspective=True)
245251

246252
if figname:
247253
fig.savefig(fname=figname)

pygmt/tests/baseline/test_pygmtlogo_circle_design.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: de3f281a09815faff7fed339c1635bc5
3+
size: 336254
4+
hash: md5
5+
path: test_pygmtlogo_circle_design_horizontal.png
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
outs:
2+
- md5: dd09fa24c575eabac7659dc49f313f5f
3+
size: 173671
4+
hash: md5
5+
path: test_pygmtlogo_circle_design_vertical.png

pygmt/tests/test_pygmtlogo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99

1010

1111
@pytest.mark.mpl_image_compare(savefig_kwargs={"dpi": 600})
12-
def test_pygmtlogo_circle_design():
12+
@pytest.mark.parametrize("wordmark", ["horizontal", "vertical"])
13+
def test_pygmtlogo_circle_design(wordmark):
1314
"""
14-
Test the design details of the PyGMT circular logo.
15+
Test the design details of the PyGMT circular logo, with a wordmark.
1516
1617
This is a regression test to ensure that the design of the logo does not change
1718
unintentionally. The debugging lines (gridlines and circles) are helpful for
1819
implementing the logo, but they are not included in the final logo design.
1920
"""
20-
fig = _create_logo(debug=True)
21+
fig = _create_logo(debug=True, wordmark=wordmark)
2122
return fig
2223

2324

0 commit comments

Comments
 (0)