Skip to content

Code PyGMT logo in PyGMT#3849

Open
yvonnefroehlich wants to merge 428 commits intomainfrom
code-pygmt-logo
Open

Code PyGMT logo in PyGMT#3849
yvonnefroehlich wants to merge 428 commits intomainfrom
code-pygmt-logo

Conversation

@yvonnefroehlich
Copy link
Copy Markdown
Member

@yvonnefroehlich yvonnefroehlich commented Mar 13, 2025

Description of proposed changes

Related to #1404 (comment), create the PyGMT logo in Python with PyGMT:

  • Python script
  • Separate method Figure.pygmtlogo or Figure.logo_pygmt as part of the Figure class or
    addition to the method Figure.logo (which plots the GMT logo)
  • Documentation
  • Tests -> only circular, color, light and dark themes
  • Gallery example -> separate PR

Related to

Preview:
https://pygmt-dev--3849.org.readthedocs.build/en/3849/api/generated/pygmt.Figure.pygmtlogo.html

image image image image
image image image image
image image image image

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

@yvonnefroehlich yvonnefroehlich added the documentation Improvements or additions to documentation label Mar 13, 2025
@yvonnefroehlich yvonnefroehlich self-assigned this Mar 13, 2025
@yvonnefroehlich yvonnefroehlich changed the title Add first version of PyGMT code for PyGMT logo POC: DOC: Code PyGMT logo in PyGMT and add as gallery example Mar 13, 2025
@yvonnefroehlich
Copy link
Copy Markdown
Member Author

/format

@michaelgrund
Copy link
Copy Markdown
Member

michaelgrund commented Mar 13, 2025

I feel the logo definition should be separated into a standalone method, similar to the method to plot the GMT logo. This would allow to plot the PyGMT logo by calling something like pygmt.Figure.pygmt_logo. The individual formats could be selected by different input parameters like you did or hex = True or darkmode = True.

Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
@yvonnefroehlich yvonnefroehlich marked this pull request as draft March 13, 2025 13:27
@yvonnefroehlich yvonnefroehlich changed the title POC: DOC: Code PyGMT logo in PyGMT and add as gallery example POC: DOC: Code PyGMT logo in PyGMT (method Figure.pygmt_logo and gallery example) Mar 13, 2025
@yvonnefroehlich yvonnefroehlich added the feature Brand new feature label Mar 13, 2025
@yvonnefroehlich yvonnefroehlich changed the title POC: DOC: Code PyGMT logo in PyGMT (method Figure.pygmt_logo and gallery example) POC: Code PyGMT logo in PyGMT (method Figure.pygmt_logo and gallery example) Mar 13, 2025
@yvonnefroehlich yvonnefroehlich changed the title POC: Code PyGMT logo in PyGMT (method Figure.pygmt_logo and gallery example) POC: Code PyGMT logo in PyGMT (method or / and gallery example) Mar 13, 2025
@yvonnefroehlich
Copy link
Copy Markdown
Member Author

ruff v0.10.0 was released 2 hours ago causing the newly falling code style checks.

Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
@seisman seisman reopened this Mar 13, 2025
@yvonnefroehlich yvonnefroehlich changed the title POC: Code PyGMT logo in PyGMT (method or / and gallery example) POC: Code PyGMT logo in PyGMT Mar 14, 2025
Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
@seisman
Copy link
Copy Markdown
Member

seisman commented Mar 16, 2025

  • separat method Figure.pygmtlogo or Figure.logo_pygmt as part of the Figure class or addition to the method Figure.logo (which plots the GMT logo)

@yvonnefroehlich You can follow the steps below:

  1. Create a pygmtlogo.py file under the pygmt/src/ directory
  2. Move the current pygmtlogo function to this file
  3. Add self as the first parameter of the pygmtlogo function
  4. Change fig.image (line 269) to self.image.
  5. Add from pygmt.src.pygmtlogo import pygmtlogo in pygmt/src/__init__.py
  6. Near line 429 in pygmt/figure.py, add pygmtlogo.

Then, you should be able to call Figure.pygmtlogo to add the logo.

Comment thread pygmt/src/pygmtlogo.py Outdated
Comment thread pygmt/src/pygmtlogo.py Outdated
Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
Comment thread pygmt/src/pygmtlogo.py Outdated
Comment thread examples/gallery/embellishments/pygmt_logo.py Outdated
@yvonnefroehlich
Copy link
Copy Markdown
Member Author

yvonnefroehlich commented Apr 29, 2026

Perhaps we can add a baseline image for the test, then merge this PR into the pygmtlogo branch and start a new PR?

I triedy adding the baseline image, but again it looks like it was not successful.

Could you please try to change the following lines

and see if the workflow works.

Seems like this helped. Thanks!

Comment thread pygmt/src/pygmtlogo.py Outdated
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@yvonnefroehlich
Copy link
Copy Markdown
Member Author

Perhaps we can add a baseline image for the test, then merge this PR into the pygmtlogo branch and start a new PR?

Sounds good!

BTW there is also the layered-animation branch which was used to create animations to show the plotting order of the single elements of the logo.

@yvonnefroehlich
Copy link
Copy Markdown
Member Author

As this PR has a very long comment and commit history, and it's difficult to quickly find a specific comment or discussion, we plan to merge this PR first and start follow-up PRs to work on open aspects. Some aspects are already (partly) addressed, and the list is probably not complete:

Comment thread pygmt/src/pygmtlogo.py Outdated
yvonnefroehlich and others added 2 commits May 1, 2026 08:00
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
outs:
- md5: 35c59c31c92f13c705a24933465ff551
size: 14374
isexec: true
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.

This line says that the pygmt/tests/baseline/test_pygmtlogo.png file has execution permission. Could you please remove the execution permission and add it agagin?

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

Labels

feature Brand new feature

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants