Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: Code PyGMT logo in PyGMT #3849

Draft
wants to merge 183 commits into
base: main
Choose a base branch
from
Draft

POC: Code PyGMT logo in PyGMT #3849

wants to merge 183 commits into from

Conversation

yvonnefroehlich
Copy link
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
  • 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)
  • Gallery example

Preview:

Related to

TODO:

  • Update intro comment of this PR
  • Remove temporary files (eps)
  • Include adding a wordmark and it's orientation to the input at the beginning
  • Update codes to finale version of the visual
  • Introduce variables
  • Improve parameter names, e.g., shape="circle" | "hexagon" or hex=False | True
  • Convert to function (remove show and rdeuce save to tempoary eps files, replot via Figure.image)
  • Remove saving as eps file for rotation (first get ride of transparent margin)
  • Remove saving as eps file for adding wordmark (different basemaps due to horizontal and vertical orientation)
  • Convert to a method of the Figure class or addition to Figure.logo.
  • Add or expand gallery example to use the method
  • Explain the story behind the logo in the gallery example

Issues:

  • Get ride of white or transparent margin
  • Currently the rotation and adding the wordmark are done in new Figure objects using the saved eps files. Maybe this is not easy to handle when converting to a method of the Figure classe.
  • Decide about font for the wordmark (font Space Grotesk by Florian Karsten not available in GMT)
  • No direct export to SVG format possible
  • etc.

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
Member Author

/format

@michaelgrund
Copy link
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.

@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
Member Author

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

Comment on lines +44 to +45
# Outer and inner radii of compass lines
r1, r2 = size * 0.625, size * 0.325
Copy link
Member

Choose a reason for hiding this comment

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

In fact, r1/r2 are not radii but x/y coordinates.

I'm thinking if we should define a few variables for different radii, e.g.,

r0 = size   # The outer radius of the blue circle
r1 = size * 0.875   # The inner radius of the blue circle
# When plotting the blue circle, the symbol size should be:
diameter = (r0+r1) / 2.0 * 2
# The pen thickness for the blue circle should be:
pen = r0 - r1

r2 = size * xxx # The outer radius of the compass line. Maybe this could be the same as the inner radius of the blue circle?
r3 = size * 0.4625   # The inner radius of the compass line
r4 = size * 0.4125   # Outer radius of the letter G
r5 = size * 0.29375  # Inner radius of the letter G 

Copy link
Member Author

Choose a reason for hiding this comment

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

I will try to find some time in the next days to give this a try 🙂.

# red line
fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}", perspective=True)

# .............................................................................
Copy link
Member

Choose a reason for hiding this comment

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

The letter M is also not perfect.

image

Instead of plotting four lines, maybe we could create a polygon?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, yeah letter M was a bit difficult to do ... And you are right using a polygon makes it easier to get perfect corners. I updated to code in commit b8d9e8c. So far the ratios are set manually, and not following any typography rules for letter M.

Old via lines New via polygon
pygmt_logo_letter_m_OLD pygmt_logo_letter_m_NEW
pygmt_logo_letter_m_OLD_zoom pygmt_logo_letter_m_NEW_zoom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature Brand new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants