Skip to content

Rename test_pygmtlogo function to test_pygmtlogo_circle_no_wordmark and improve it#4617

Open
seisman wants to merge 2 commits intopygmtlogofrom
pygmtlogo-test
Open

Rename test_pygmtlogo function to test_pygmtlogo_circle_no_wordmark and improve it#4617
seisman wants to merge 2 commits intopygmtlogofrom
pygmtlogo-test

Conversation

@seisman
Copy link
Copy Markdown
Member

@seisman seisman commented May 2, 2026

As shown in the table in PR #4616, we will likely have 24 PyGMT logo variants. Maintaining 24 separate baseline images is impractical, so we plan to group multiple variants into a single test. A reasonable approach is to define six tests based on logo shape and wordmark configuration. Each test would include four variants: colored and black-and-white logos in both light and dark themes.

This PR renames the existing test from test_pygmtlogo (which is too general) to test_pygmtlogo_circle_no_wordmark. It also adds a basemap to make the default logo size easier to inspect.

It appears that the default width/height of the logos is slightly smaller than 2 cm, although I am not sure why this value is used.

@seisman seisman requested a review from yvonnefroehlich May 2, 2026 12:58
@seisman seisman added the maintenance Boring but important stuff for the core devs label May 2, 2026
@seisman seisman added this to the 0.19.0 milestone May 2, 2026
@pytest.mark.benchmark
@pytest.mark.mpl_image_compare
def test_pygmtlogo():
def test_pygmtlogo_circle_no_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.

Other tests will be named like

  • test_pygmtlogo_circle_horizontal_wordmark
  • test_pygmtlogo_circle_vertical_wordmark
  • test_pygmtlogo_hexagon_no_wordmark
  • test_pygmtlogo_hexagon_horizontal_wordmark
  • test_pygmtlogo_hexagon_vertical_wordmark

)
fig.pygmtlogo(
position=Position((4, 1), anchor="CM", cstype="mapcoords"), theme="dark"
)
Copy link
Copy Markdown
Member Author

@seisman seisman May 2, 2026

Choose a reason for hiding this comment

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

Plan to add the two black-and-white logos below the colored versions in later PRs.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

Status Path
added pygmt/tests/baseline/test_pygmtlogo_circle_no_wordmark.png

Image diff(s)

Details

Added images

  • test_pygmtlogo_circle_no_wordmark.png

Modified images

Path Old New

Report last updated at commit de990cc

@seisman
Copy link
Copy Markdown
Member Author

seisman commented May 2, 2026

It appears that the default width/height of the logos is slightly smaller than 2 cm, although I am not sure why this value is used.

One question, should we use the default logo size? I have no idea how the value is determined.

The default GMT logo is 2.54 cm high, and the "no label" version is close to 2 cm. Maybe we should force the PyGMT logo height to 2-cm for the no-wordmark and horizontal-wordmark version, and width to 2-cm for the vertical-wordmark version?

import pygmt
from pygmt.params import Position

fig = pygmt.Figure()
fig.basemap(region=[0, 8, 0, 2], projection="x1c", frame="g1")
fig.logo(style="no_label")
fig.pygmtlogo(position=(6, 0))
fig.show()
logos

@yvonnefroehlich
Copy link
Copy Markdown
Member

yvonnefroehlich commented May 2, 2026

It appears that the default width/height of the logos is slightly smaller than 2 cm, although I am not sure why this value is used.

One question, should we use the default logo size? I have no idea how the value is determined.

The default GMT logo is 2.54 cm high, and the "no label" version is close to 2 cm. Maybe we should force the PyGMT logo height to 2-cm for the no-wordmark and horizontal-wordmark version, and width to 2-cm for the vertical-wordmark version?

Hmm. This is an interesting question! I have to think about this tomorrow in more detail to understand the behaviour.

Currently we have in _create_logo:

size = 4
region = [-size, size] * 2   # -> 8 plot-units
proj = "x1c"   # -> 1 cm per plot-units

I thougth the PyGMT logo saved to a file will have a size (diameter) of 8 cm for the circle version without wordmark.
For the PNG format (right), the default size is as expected when adding the image via Figure.image (code is at the end of the comment). But for the EPS format (left), the default size seems to be different:
image


Generating the PNG and EPS files with

size = 1
region = [-size, size] * 2
proj = "x1c"

Leads to:
image


Setting position="jMC+jMC+w2c gives:
image


Code:

import pygmt

fig = pygmt.Figure()

fig.basemap(region=[-4, 4] * 2, projection="x1c", frame=1)
fig.image(imagefile="pygmt_logo_saved_external.eps")#, position="jMC+jMC+w2c")
fig.basemap(frame="g1")

fig.shift_origin(xshift="+w+1c")

fig.basemap(region=[-4, 4] * 2, projection="x1c", frame=1)
fig.image(imagefile="pygmt_logo_saved_external.png")#, position="jMC+jMC+w2c")
fig.basemap(frame="g1")

fig.show()

@seisman
Copy link
Copy Markdown
Member Author

seisman commented May 3, 2026

From the image source code, it seems the default size is controlled by the GMT_GRAPHICS_DPU setting, which defaults to 300 dots per inch.

@yvonnefroehlich
Copy link
Copy Markdown
Member

yvonnefroehlich commented May 3, 2026

From the image source code, it seems the default size is controlled by the GMT_GRAPHICS_DPU setting, which defaults to 300 dots per inch.

Thanks for potting out this parameter, I did not know about it and that it affects the image module.

Currently we have

size = 4
region = [-size, size] * 2   # -> 8 plot-units
proj = "x1c"   # -> 1 cm per plot-units

with GMT_GRAPHICS_DPU = 300 (default).

By only adding the logo image in EPS format (without a basemap) and using -V we can manually find out the width and hight after applying Figure.image. For the circle version (without the wordmark) the width (or hight) is the diameter.

import pygmt

fig = pygmt.Figure()
fig.image(imagefile="pygmt_logo_saved_external.eps")  # Logo is circle; use no basemap 
fig.show(V=True)

psconvert [INFORMATION]: Figure dimensions: Width: 54.4932 points [1.9224 cm] Height: 54.4932 points [1.9224 cm]

So we could either adjust size or GMT_GRAPHICS_DPU to make the default size of the logo (added via Figure.image using the EPS format) match 2 cm:

  • size = (4 / 1.9224) * 2 = 4.161464835622139
  • GMT_GRAPHICS_DPU = 300 - ((300/1.9224) * 2 - 300) = 287.8901373283396

Figure dimensions: Width: 56.7848 points [2.00324 cm] Height: 56.7848 points [2.00324 cm]

Not sure if this is an ideal solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants