Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
427 commits
Select commit Hold shift + click to select a range
e86f164
Improve region and projection arguments
yvonnefroehlich Apr 8, 2025
ed4a782
Adjust pen for arrow
yvonnefroehlich Apr 9, 2025
7fcbc03
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 9, 2025
e0ede2e
First version of polygon for letter M
yvonnefroehlich Apr 10, 2025
b8d9e8c
Get ride of the xshift for letter M
yvonnefroehlich Apr 10, 2025
17c3503
Fine tune x and y values
yvonnefroehlich Apr 10, 2025
80a1487
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 19, 2025
08b3551
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Jun 1, 2025
f396ac0
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Jun 10, 2025
e432f79
Improve comment
yvonnefroehlich Jun 11, 2025
fae8282
Use match case for theme
yvonnefroehlich Jun 11, 2025
e015226
Use case match for shpae
yvonnefroehlich Jun 11, 2025
aee2574
Use full line length
yvonnefroehlich Jun 11, 2025
57fe4a9
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Jun 11, 2025
0eacfa9
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Jul 7, 2025
2a1464a
Save seperation lines
yvonnefroehlich Jul 24, 2025
a2c3da8
Remove seperation lines
yvonnefroehlich Jul 24, 2025
0042ed9
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Jul 24, 2025
c46658d
Fix typo
yvonnefroehlich Aug 6, 2025
f7082c4
Use line length
yvonnefroehlich Aug 6, 2025
ba7f14d
Add perspective parameter for letter M
yvonnefroehlich Aug 6, 2025
1e3bea4
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Aug 6, 2025
faa61dd
Define radii
yvonnefroehlich Aug 6, 2025
b75dbad
Improve code for compass
yvonnefroehlich Aug 6, 2025
5e345e5
Draw letter G via x/y coordinates
yvonnefroehlich Aug 6, 2025
3ffbcdf
Add numpy import
yvonnefroehlich Aug 6, 2025
d49633a
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Aug 19, 2025
76dec8b
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Aug 25, 2025
ff77fe8
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Aug 27, 2025
86ded86
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Sep 4, 2025
b352346
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Sep 6, 2025
97ce3d7
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Sep 24, 2025
97ee7dc
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Oct 3, 2025
a546342
Use basemap and allow adding frame and gridlines for debugging
yvonnefroehlich Nov 3, 2025
4003b3c
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 3, 2025
ec5be4a
Use variables
yvonnefroehlich Nov 3, 2025
0584284
Add vertical line back
yvonnefroehlich Nov 3, 2025
d66c7b6
Use variable
yvonnefroehlich Nov 4, 2025
0949d19
Use variable (leeter G)
yvonnefroehlich Nov 4, 2025
bb3bf23
Use half of the pen thickness of compass lines for
yvonnefroehlich Nov 4, 2025
ee94768
Calculate the position of letter M (sligthly above letter G)
yvonnefroehlich Nov 4, 2025
9072f0d
Add extra vertical compass line above letters "G" and "M"
yvonnefroehlich Nov 4, 2025
a98d25c
Remove not needed return value
yvonnefroehlich Nov 4, 2025
9de8f2e
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 4, 2025
b9de084
Improve plotting the curved horizontal line and the arrow
yvonnefroehlich Nov 4, 2025
4b8e3b6
Add background color
yvonnefroehlich Nov 4, 2025
29910ac
Follow line length limit
yvonnefroehlich Nov 4, 2025
aa6d936
Add perspective parameter for curved horizontal line of letter T
yvonnefroehlich Nov 4, 2025
7cab1bb
Introduce radius for outer limit of curved horizontal line for letter T
yvonnefroehlich Nov 4, 2025
039bad4
Remove frame and circles for orientation
yvonnefroehlich Nov 4, 2025
3e8ae21
Update parameter names in tests
yvonnefroehlich Nov 4, 2025
12be397
Remove tab by white spaces
yvonnefroehlich Nov 4, 2025
5453d16
Remove unneeded comment
yvonnefroehlich Nov 5, 2025
19c0d18
Adjust length of vertical line of compass
yvonnefroehlich Nov 5, 2025
87ba6cf
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 5, 2025
a272a09
Adjust compass line ending at upper right corner of letter M
yvonnefroehlich Nov 5, 2025
4bd8130
Define pen thickness
yvonnefroehlich Nov 6, 2025
193f725
Fix code of orientation circles
yvonnefroehlich Nov 6, 2025
22ecb94
Improve some comments
yvonnefroehlich Nov 7, 2025
ef619bc
Plot only lower part of vertical compass line
yvonnefroehlich Nov 7, 2025
255f7fe
Use a slightly smaller arrow head for letter T
yvonnefroehlich Nov 7, 2025
94f09d7
Remove 'color' from variable names
yvonnefroehlich Nov 7, 2025
7afd52e
Add just radius for arrow
yvonnefroehlich Nov 7, 2025
354e9a2
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 7, 2025
f994c9a
Out-comment fig.show
yvonnefroehlich Nov 7, 2025
f4269bb
Adjust position of horizontal wordmark
yvonnefroehlich Nov 7, 2025
afe3be6
Adjust position of vertical wordmark
yvonnefroehlich Nov 7, 2025
736e60f
Adjust position of wordmark
yvonnefroehlich Nov 7, 2025
0d8b931
Fit hexagon into circles
yvonnefroehlich Nov 7, 2025
fd93480
Correct horizontal compass line to be on top of Earth out line
yvonnefroehlich Nov 7, 2025
5e8bd7e
Reorder parameters in function definition
yvonnefroehlich Nov 8, 2025
c8be168
Reorder docstrings
yvonnefroehlich Nov 8, 2025
2273713
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 8, 2025
1400ab6
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 8, 2025
fdbca4a
Import typing
yvonnefroehlich Nov 9, 2025
8a79a38
Un-commend fig.show
yvonnefroehlich Nov 10, 2025
1b107dc
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 10, 2025
43f79af
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 10, 2025
26c6dce
Use line length
yvonnefroehlich Nov 15, 2025
98bcad8
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 15, 2025
efba97a
Polish
yvonnefroehlich Nov 18, 2025
c430948
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 18, 2025
b7d75e5
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 19, 2025
e0b61c8
Update comment
yvonnefroehlich Nov 19, 2025
64f6c9a
Do not invert wordmark text in gray20, always use gray20
yvonnefroehlich Nov 21, 2025
bb31966
Revert "Do not invert wordmark text in gray20, always use gray20"
yvonnefroehlich Nov 21, 2025
8b1fd34
Reduce examples
yvonnefroehlich Nov 21, 2025
f88f30f
Uncomment fig.show
yvonnefroehlich Nov 21, 2025
b238479
Not help gridlines
yvonnefroehlich Nov 21, 2025
93c8ff5
Adjust background color in example
yvonnefroehlich Nov 21, 2025
b37e24e
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 23, 2025
3d030d8
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Nov 29, 2025
1d031be
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Jan 5, 2026
1deb35c
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Jan 12, 2026
f70d2db
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Feb 5, 2026
abc89a6
Exclude PLR0915
yvonnefroehlich Feb 5, 2026
27937b5
Add pygmt import
yvonnefroehlich Feb 5, 2026
4ed27a7
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Mar 21, 2026
5953cc6
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 1, 2026
aad7292
Adjust line length
yvonnefroehlich Apr 1, 2026
194b15d
Use new pythonic code for no frame
yvonnefroehlich Apr 1, 2026
f6e9b01
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 7, 2026
9920f90
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 12, 2026
12005a7
Define private functions for letter coordinates
yvonnefroehlich Apr 13, 2026
da985c6
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 13, 2026
a585464
Make private function
yvonnefroehlich Apr 14, 2026
01f7c69
Add comment
yvonnefroehlich Apr 14, 2026
5da7271
Fix
yvonnefroehlich Apr 14, 2026
adfd925
Use easier to understand code for letter G
yvonnefroehlich Apr 14, 2026
625a1ff
Use shorter way to set maximum length
yvonnefroehlich Apr 16, 2026
a44dc64
Use shorter way to set zero as start
yvonnefroehlich Apr 16, 2026
0a006bb
Remove close=True
yvonnefroehlich Apr 16, 2026
7333e59
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 16, 2026
31955c6
Use more compact definition of letter G
yvonnefroehlich Apr 16, 2026
da0a5ef
Make coordinate calculation for curved top line of letter T clearer
yvonnefroehlich Apr 16, 2026
cada956
Add name for private function for letter G
yvonnefroehlich Apr 17, 2026
46f3cbf
Add name for private function for letter T
yvonnefroehlich Apr 17, 2026
3e6c4ba
Add name for private function for letter M
yvonnefroehlich Apr 17, 2026
9257aae
Combine comment lines
yvonnefroehlich Apr 17, 2026
e6c21bd
Make compass line consisten with the defined thicknesses
yvonnefroehlich Apr 17, 2026
e9f6594
Remove comment
yvonnefroehlich Apr 18, 2026
b9a262d
Add private function for compass lines
yvonnefroehlich Apr 18, 2026
f226cac
Fix indent
yvonnefroehlich Apr 18, 2026
28e055b
Define private function for vertical red line
yvonnefroehlich Apr 18, 2026
2f92899
Make variable names consistent
yvonnefroehlich Apr 18, 2026
832d836
Make variable names consistent
yvonnefroehlich Apr 18, 2026
346c655
Add and improve private function names
yvonnefroehlich Apr 18, 2026
a57bb5c
Remove unneeded comments
yvonnefroehlich Apr 18, 2026
23b6386
Move docs to plot function
yvonnefroehlich Apr 18, 2026
e3d6e0c
Fix mixed return onf red line coordinates
yvonnefroehlich Apr 18, 2026
1bb046b
Fix typo
yvonnefroehlich Apr 18, 2026
24c8760
Improve coordinates of letter M
yvonnefroehlich Apr 19, 2026
44ba985
Introduce a third pen thickness for letters
yvonnefroehlich Apr 19, 2026
70f6784
Return dicts by private functions
yvonnefroehlich Apr 19, 2026
adc2d78
Introduce third pen thickness for letters
yvonnefroehlich Apr 19, 2026
e730197
Add blank lines to improved readability of the code
yvonnefroehlich Apr 19, 2026
979050c
Change thick to thicker and middle to thick
yvonnefroehlich Apr 19, 2026
a7f326c
Define fourth pen thickness 'thinner' for letter M to define variable…
yvonnefroehlich Apr 19, 2026
0175f7f
Remove old definition of letter M, improve definition of m_y1
yvonnefroehlich Apr 19, 2026
8f9e32e
Make gaps consistent
yvonnefroehlich Apr 19, 2026
c60018e
Use pen thickness variable
yvonnefroehlich Apr 19, 2026
8001dd2
Use for descripte variable names for pen thicknesses and introduce pe…
yvonnefroehlich Apr 19, 2026
af31fa2
Redefine coordinates for letter M
yvonnefroehlich Apr 19, 2026
61ae0c8
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 19, 2026
9c2c36f
Use variable "thick_gt"
yvonnefroehlich Apr 19, 2026
130d1c3
Simplify condition for mask for letter T
yvonnefroehlich Apr 19, 2026
1a73708
Shorten variable names for coordinates of letter M
yvonnefroehlich Apr 19, 2026
0789876
Make gap for arrow head consistent with the other gaps
yvonnefroehlich Apr 19, 2026
a00e695
Improve comment
yvonnefroehlich Apr 19, 2026
bafc7a0
Define compass lines as vectors
yvonnefroehlich Apr 19, 2026
9b4bd13
Fix typo
yvonnefroehlich Apr 19, 2026
6e7fc83
Fix typo
yvonnefroehlich Apr 19, 2026
f171ab4
Add note regarding radii
yvonnefroehlich Apr 19, 2026
d0c8fda
Fix line length, add more help lines
yvonnefroehlich Apr 19, 2026
1766e9c
Define variable x3 for curved top line of letter T
yvonnefroehlich Apr 19, 2026
7f563e1
Add one more helping line
yvonnefroehlich Apr 19, 2026
fe109d9
Use finer discretization for clean endings of top curved line of lett…
yvonnefroehlich Apr 20, 2026
1e889d2
Calculate compass line thickness from the thickness of the souronding…
yvonnefroehlich Apr 20, 2026
47b2ca3
Remove inner compass lines
yvonnefroehlich Apr 20, 2026
7da6093
Fix typos
yvonnefroehlich Apr 20, 2026
73dc51a
Adjust radii and use fractional representation
yvonnefroehlich Apr 20, 2026
0413225
Adjust thickness of gap
yvonnefroehlich Apr 20, 2026
393a3c4
Plot red vertical line as polygon
yvonnefroehlich Apr 20, 2026
8067fba
Limit all compass lines to abs(r1)
yvonnefroehlich Apr 20, 2026
c78c89c
Remove unneeded variable
yvonnefroehlich Apr 20, 2026
718c7a2
Reorder code, improve comments
yvonnefroehlich Apr 20, 2026
20b5d74
Add comment to explain plotting order
yvonnefroehlich Apr 20, 2026
537e750
Improve plotting order
yvonnefroehlich Apr 20, 2026
0515240
Add debug parameter to add helping lines
yvonnefroehlich Apr 20, 2026
89bd0af
TEST: Adjustments for hexagon shape
yvonnefroehlich Apr 20, 2026
7f8f99b
Remove old code parts
yvonnefroehlich Apr 20, 2026
97d1af1
Use max line length
yvonnefroehlich Apr 20, 2026
8df1bba
Plot vertical help lines in one plot call
yvonnefroehlich Apr 20, 2026
a27a6b4
Sorten descripition of function create_logo
yvonnefroehlich Apr 21, 2026
ca0eb16
Remove unneeded comment due to remove of inner compass lines
yvonnefroehlich Apr 21, 2026
7d96502
Remove seperator
yvonnefroehlich Apr 21, 2026
8fa1dee
Set coordinates in plot call for shape
yvonnefroehlich Apr 21, 2026
b120249
Remove fig.show
yvonnefroehlich Apr 21, 2026
ce173ec
Make create_logo a private function
yvonnefroehlich Apr 21, 2026
409ab84
Allow setting hight and width for adding logo to the plot
yvonnefroehlich Apr 21, 2026
894a51c
Add inline example
yvonnefroehlich Apr 21, 2026
fea12d4
Add perspective for helping lines
yvonnefroehlich Apr 21, 2026
c93c4bf
Limit helping lines to fit into frame even after rotation
yvonnefroehlich Apr 21, 2026
a0a38a4
Shorten variable name to fit into one line
yvonnefroehlich Apr 21, 2026
ab997e0
Try if code fits in one line
yvonnefroehlich Apr 21, 2026
cd3bb62
Try if code fits in one line
yvonnefroehlich Apr 21, 2026
6ad9690
Combine compass lines into one plot call
yvonnefroehlich Apr 21, 2026
4a522c6
TEST: Adjustments for hexagon shape size of r0
yvonnefroehlich Apr 21, 2026
5989fad
Calculate curved top line of letter T based on South at 270 deg
yvonnefroehlich Apr 21, 2026
8f9f8d0
Use 'thick_shape" for drawing outline for black-white dark case
yvonnefroehlich Apr 21, 2026
23b3e39
TEST: Adjustments for hexagon shape size of r0+0.35
yvonnefroehlich Apr 21, 2026
d60a057
Define letter T entierly via a polygon
yvonnefroehlich Apr 21, 2026
e1c8964
Fixes for hexagon shape
yvonnefroehlich Apr 21, 2026
98768a9
Adjust function explanation for letter T
yvonnefroehlich Apr 21, 2026
a5ba62a
Combine comment for letters
yvonnefroehlich Apr 21, 2026
6b85259
Plot background line and arrow together
yvonnefroehlich Apr 21, 2026
23bed9a
Merge remote-tracking branch 'origin/code-pygmt-logo' into code-pygmt…
yvonnefroehlich Apr 21, 2026
fa628d5
Adjust gap for arrow
yvonnefroehlich Apr 21, 2026
96c9ed2
Adjust size of arrow head
yvonnefroehlich Apr 21, 2026
01e6a41
Merge remote-tracking branch 'origin/code-pygmt-logo' into code-pygmt…
yvonnefroehlich Apr 21, 2026
2964869
Fix line length
yvonnefroehlich Apr 21, 2026
7efd08d
Remove gallery example
yvonnefroehlich Apr 21, 2026
160dcdf
Update and add tests
yvonnefroehlich Apr 21, 2026
8bc5a82
Plot vertical line and arrow head as one polygon
yvonnefroehlich Apr 22, 2026
99aa2f5
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 22, 2026
562ffa4
Fix typo
yvonnefroehlich Apr 22, 2026
bf3d637
Reduce tests
yvonnefroehlich Apr 22, 2026
fb23907
Update intro text
yvonnefroehlich Apr 22, 2026
698ddd7
Remove fig.show()
yvonnefroehlich Apr 22, 2026
04f2ca5
Remove the projection and region parameters
yvonnefroehlich Apr 22, 2026
59e56cb
Adjust formating of comments
yvonnefroehlich Apr 22, 2026
25b55ad
Simplify calculation of thickness
yvonnefroehlich Apr 22, 2026
13ad3b6
Remove region and projection parameters
yvonnefroehlich Apr 22, 2026
729aa00
No wordmark by default
yvonnefroehlich Apr 23, 2026
fac0aba
Import pygmt into private function
yvonnefroehlich Apr 24, 2026
ece8214
Move definition of perspective
yvonnefroehlich Apr 24, 2026
8778443
Use wordmark="none" instead of wordmark=False
yvonnefroehlich Apr 24, 2026
1c1406c
Use GMTTempoaryFile and pass a tempoary file
yvonnefroehlich Apr 24, 2026
7486e66
Improve description of test
yvonnefroehlich Apr 24, 2026
74ab006
Fix style
yvonnefroehlich Apr 24, 2026
a4e378f
Add import of GMTTempFile
yvonnefroehlich Apr 25, 2026
ee1951d
Move import below docstring
yvonnefroehlich Apr 25, 2026
8ae5c89
Fix file name variable
yvonnefroehlich Apr 25, 2026
3cb5212
Combine tests
yvonnefroehlich Apr 25, 2026
0291e93
Add type hints
yvonnefroehlich Apr 26, 2026
afa0887
Shorten docstring for theme
yvonnefroehlich Apr 26, 2026
de187e2
Use list for docstring of wordmark
yvonnefroehlich Apr 26, 2026
ee85374
Shorten docstring for color
yvonnefroehlich Apr 26, 2026
382e288
Remove deleting file
yvonnefroehlich Apr 26, 2026
5b28739
Add perspective parameter
yvonnefroehlich Apr 26, 2026
9fc6c78
Import GMTTempFile at the beginning
yvonnefroehlich Apr 27, 2026
f2d2922
Sorten comment for perspective parameter
yvonnefroehlich Apr 27, 2026
6aafe47
Update inline example
yvonnefroehlich Apr 28, 2026
6cdce1b
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 28, 2026
862c9cd
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 29, 2026
1c51189
Fix parameter name in test
yvonnefroehlich Apr 29, 2026
124d21a
Add test_pygmtlogo.png into DVC
Apr 29, 2026
6878e26
Remove execution permission
yvonnefroehlich Apr 29, 2026
194c3e0
Adjust workflow dvc-diff
yvonnefroehlich Apr 29, 2026
0ed5cc9
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich Apr 29, 2026
c614cdb
Use int for hex_factor
yvonnefroehlich Apr 29, 2026
3597bd5
Give radii in a fraction of 128
yvonnefroehlich Apr 29, 2026
4bc9f68
Extend docstrings
yvonnefroehlich Apr 30, 2026
4a9c09b
Fix docstrings taken from helpers
yvonnefroehlich Apr 30, 2026
1cb524c
Improve comment for inline example
yvonnefroehlich Apr 30, 2026
58123a7
Add docstring for position parameter
yvonnefroehlich Apr 30, 2026
47699a8
Add docstrings for width, height, and box
yvonnefroehlich Apr 30, 2026
ec3b72d
Use full line length
yvonnefroehlich May 1, 2026
816178a
Merge branch 'main' into code-pygmt-logo
yvonnefroehlich May 1, 2026
31972c2
Add pygmtlogo to figure.py
yvonnefroehlich May 1, 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
1 change: 1 addition & 0 deletions doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Plotting figure elements
Figure.logo
Figure.magnetic_rose
Figure.paragraph
Figure.pygmtlogo
Figure.scalebar
Figure.solar
Figure.text
Expand Down
2 changes: 2 additions & 0 deletions pygmt/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from pygmt.src.plot import plot as _plot
from pygmt.src.plot3d import plot3d as _plot3d
from pygmt.src.psconvert import psconvert as _psconvert
from pygmt.src.pygmtlogo import pygmtlogo as _pygmtlogo
from pygmt.src.rose import rose as _rose
from pygmt.src.scalebar import scalebar as _scalebar
from pygmt.src.shift_origin import shift_origin as _shift_origin
Expand Down Expand Up @@ -464,6 +465,7 @@ def _repr_html_(self) -> str:
plot = _plot
plot3d = _plot3d
psconvert = _psconvert
pygmtlogo = _pygmtlogo
rose = _rose
scalebar = _scalebar
set_panel = _set_panel
Expand Down
360 changes: 360 additions & 0 deletions pygmt/src/pygmtlogo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,360 @@
"""
pygmtlogo - Plot the PyGMT logo.

The initial design of the logo is kindly provided by `@sfrooti <https://github.com/sfrooti>`_
and consists of a visual and the wordmark "PyGMT".
"""

from collections.abc import Sequence
from typing import Literal

import numpy as np
Comment thread
yvonnefroehlich marked this conversation as resolved.
from pygmt._typing import AnchorCode, PathLike
Comment thread
yvonnefroehlich marked this conversation as resolved.
from pygmt.helpers import GMTTempFile, fmt_docstring
from pygmt.params import Box, Position

__doctest_skip__ = ["pygmtlogo"]


def _create_logo( # noqa: PLR0915
shape: Literal["circle", "hexagon"] = "circle",
theme: Literal["light", "dark"] = "light",
wordmark: Literal["none", "horizontal", "vertical"] = "none",
color: bool = True,
Comment thread
yvonnefroehlich marked this conversation as resolved.
figname: PathLike = "pygmt_logo.eps",
debug: bool = False,
):
"""
Create the PyGMT logo using PyGMT.
"""
Comment thread
yvonnefroehlich marked this conversation as resolved.
from pygmt.figure import Figure # noqa: PLC0415

# Helpful definitions
size = 4
region = [-size, size] * 2
proj = "x1c"
Comment thread
yvonnefroehlich marked this conversation as resolved.
# Rotation around z-axis by 30 degrees counter-clockwise placed in the center.
perspective = "30+w0/0"

# Radii (make sure that r4-r5 == r2-r3)
r0, r1, r2, r3, r4, r5 = size * np.array([128, 112, 75, 61, 53, 39]) / 128
# Pen thicknesses
thick_shape = r0 - r1 # for shape
thick_gt = r4 - r5 # for letters G and T
thick_m = r4 / 5 # for letter M
thick_comp = thick_shape / 3 # for compass lines
thick_gap = thick_shape / 4

# Define colors
color_light = "white"
color_dark = "gray20"

blue = "48/105/152" # Python blue
yellow = "255/212/59" # Python yellow
red = "238/86/52" # GMT red
if not color:
blue = yellow = red = color_dark
if theme == "dark":
blue = yellow = red = color_light

# Background and wordmark
match theme:
case "light":
color_bg = color_light
color_py = blue
color_gmt = color_dark
case "dark":
color_bg = color_dark
color_py = yellow
color_gmt = color_light

# Define shape
match shape:
case "circle":
symbol = "c"
size_shape = r0 + r1
hex_factor = 1.0
case "hexagon":
symbol = "h"
size_shape = (r0 + 0.34) * 2
hex_factor = 1.1

# Define wordmark
font = "AvantGarde-Book"
match wordmark:
case "vertical":
args_text_wm = {"x": 0, "y": -4.5, "justify": "CT", "font": f"2.5c,{font}"}
case "horizontal":
args_text_wm = {"x": 4.5, "y": 0.8, "justify": "LM", "font": f"8c,{font}"}

def _letter_g_coords():
"""Coordinates for letter G."""
outer_angles = np.deg2rad(np.arange(90, 361))
inner_angles = outer_angles[::-1]
offset = thick_gt / 2
# Outer arc (r4)
arc_outer_x, arc_outer_y = np.cos(outer_angles) * r4, np.sin(outer_angles) * r4
# Connecting lines
connector_x, connector_y = [r4, 0, 0, r5], [offset, offset, -offset, -offset]
# Inner arc (r5)
arc_inner_x, arc_inner_y = np.cos(inner_angles) * r5, np.sin(inner_angles) * r5
# Combine all coordinates (outer arc, connectors, inner arc)
g_x = np.concatenate([arc_outer_x, connector_x, arc_inner_x])
g_y = np.concatenate([arc_outer_y, connector_y, arc_inner_y])
return {"x": g_x, "y": g_y}

def _letter_m_coords():
"""Coordinates for letter M."""
# X-coordinates from left to right.
x1 = thick_gap # Left edge of left vertical line of M.
x5 = r4 # Right edge of right vertical line of M.
x2 = x1 + thick_m # Right edge of left vertical line of M.
x3 = (x1 + x5) / 2 # The middle of M.
x4 = x5 - thick_m # Left edge of right vertical line of M.
# Y-coordinates from bottom to top.
y1 = thick_gt / 2 + thick_gap # Bottom of the letter M.
y2 = r5 - thick_gt # Bottom of the middle peak of M.
y3 = r5 # Top of the middle peak of M.
y4 = r4 # Top of letter M.
# X- and Y-coordinates of the letter M, starting from the left edge of the left
# vertical line and going clockwise.
m_x = [x1, x1, x2, x3, x4, x5, x5, x4, x4, x3, x2, x2]
m_y = [y1, y4, y4, y3, y4, y4, y1, y1, y3, y2, y3, y1]
return {"x": m_x, "y": m_y}

def _letter_t_coords():
"""Coordinates for letter T."""
outer_angles = np.deg2rad(np.arange(240, 300, 0.5))
inner_angles = outer_angles[::-1]
arc_outer_x, arc_outer_y = np.cos(outer_angles) * r2, np.sin(outer_angles) * r2
arc_inner_x, arc_inner_y = np.cos(inner_angles) * r3, np.sin(inner_angles) * r3
# The arrowhead is an equilateral triangle
x0 = thick_gt / 2 # Extra half-width for arrow head
y0 = 1.8 * x0 * np.sqrt(3) # Height for arrow head
arrow_x = [-x0, -x0, -x0 * 2.0, 0, x0 * 2.0, x0, x0]
arrow_y = [-r2, -r0 + y0, -r0 + y0, -r0, -r0 + y0, -r0 + y0, -r2]
mask_left = arc_outer_x < -x0
mask_right = arc_outer_x > x0
t_x = np.concatenate(
[arc_inner_x, arc_outer_x[mask_left], arrow_x, arc_outer_x[mask_right]]
)
t_y = np.concatenate(
[arc_inner_y, arc_outer_y[mask_left], arrow_y, arc_outer_y[mask_right]]
)
# Ensure the same X-coordinate for the right edge of T and the middle of M.
mask = np.abs(t_x) <= (thick_gap + r4) / 2
return {"x": t_x[mask], "y": t_y[mask]}

def _bg_arrow_coords():
"""Coordinates for the background arrow."""
# x0, y0 is the same as in _letter_t_coords().
x0 = thick_gt / 2
y0 = 1.8 * x0 * np.sqrt(3)
# The background arrow is thick_comp wider than the letter T.
x1 = x0 + thick_comp / 2.0 # Half-width of the arrow tail
x2 = 2 * x0 + thick_comp / np.sqrt(3) # Half-width of the arrow head

arrow_x = [-x1, -x1, -x2, -(x2 - 2 * x0), (x2 - 2 * x0), x2, x1, x1]
arrow_y = [r0, -r0 + y0, -r0 + y0, -r0, -r0, -r0 + y0, -r0 + y0, r0]
return {"x": arrow_x, "y": arrow_y}

def _compass_lines():
"""Coordinates of compass lines."""
sqrt2 = np.sqrt(2) / 2
x1, x2, x3 = r0 * sqrt2, r3 * sqrt2, (r2 + (r3 - r4)) * sqrt2
# Coordinates of vectors in the format of (x_start, y_start, x_end, y_end).
return [
(-r0 * hex_factor, 0, -r3, 0), # left horizontal
(r3, 0, r0 * hex_factor, 0), # right horizontal
(-x1, x1, -x2, x2), # upper left
(-x1, -x1, -x2, -x2), # lower left
(x1, x1, x3, x3), # upper right
(x1, -x1, x2, -x2), # lower right
]

def _vline_coords():
"""
Coordinates for the vertical line at the top.
"""
x0 = thick_gt / 2
return {"x": [-x0, -x0, x0, x0], "y": [r0, r3, r3, r0]}

fig = Figure()
fig.basemap(region=region, projection=proj, perspective=perspective, frame="none")

# Earth - circle / hexagon
args_shape = {
"style": f"{symbol}{size_shape}c",
"perspective": True,
"no_clip": True, # Needed for corners of hexagon shape
}
# Shape fill
fig.plot(x=0, y=0, fill=color_bg, **args_shape)

# Compass lines
fig.plot(
data=_compass_lines(),
pen=f"{thick_comp}c,{yellow}",
style="v0c+s",
perspective=True,
no_clip=True,
)

# Shape outline (over ends of compass lines for hexagon shape)
fig.plot(x=0, y=0, pen=f"{thick_shape}c,{blue}", **args_shape)

# Arrow in background color (over shape outline but under letters)
fig.plot(data=_bg_arrow_coords(), fill=color_bg, perspective=True)
Comment thread
yvonnefroehlich marked this conversation as resolved.

# Letters G, M, and T
fig.plot(data=_letter_g_coords(), fill=red, perspective=True)
fig.plot(data=_letter_m_coords(), fill=red, perspective=True)
fig.plot(data=_letter_t_coords(), fill=red, perspective=True)

# Upper vertical line
fig.plot(data=_vline_coords(), fill=red, perspective=True)

# Outline around the shape for black and white color with dark theme
if not color and theme == "dark":
fig.plot(
x=0,
y=0,
style=f"{symbol}{size_shape + thick_shape}c",
pen=f"1p,{color_dark}",
perspective=True,
no_clip=True,
)

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

# Helpful for implementing the logo; not included in the logo
if debug:
Comment thread
yvonnefroehlich marked this conversation as resolved.
from pygmt import config # noqa: PLC0415

# Gridlines
with config(MAP_FRAME_TYPE="inside", MAP_GRID_PEN="0.1p,gray30"):
fig.basemap(frame="g1")
# Circles for the different radii
for r in [r0, r1, r2, r3, r4, r5]:
fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.3p,gray30")
pen = "0.3p,gray30,2_2"
fig.plot(x=0, y=0, style=f"c{2 * (r2 + (r3 - r4))}c", pen=pen)
# Lines for letter M
fig.hlines(y=[r4, r5], xmin=-3, pen=pen, perspective=True)
fig.vlines(x=[r4, (thick_gap + r4) / 2], ymax=3, pen=pen, perspective=True)

fig.savefig(fname=figname)


@fmt_docstring
def pygmtlogo( # noqa: PLR0913
self,
shape: Literal["circle", "hexagon"] = "circle",
theme: Literal["light", "dark"] = "light",
wordmark: Literal["none", "horizontal", "vertical"] = "none",
color: bool = True,
width: float | str | None = None,
height: float | str | None = None,
position: Position | Sequence[float | str] | AnchorCode | None = None,
box: Box | bool = False,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
panel: int | Sequence[int] | bool = False,
perspective: float | Sequence[float] | str | bool = False,
transparency: float | None = None,
):
r"""
Plot the PyGMT logo.
The design of the logo is kindly provided by `@sfrooti <https://github.com/sfrooti>`_
and consists of a visual and the wordmark "PyGMT".

Parameters
----------
shape
Shape of the visual logo. Use ``"circle"`` for a circle shape [Default] or
``"hexagon"`` for a hexagon shape.
theme
Use ``"light"`` for light mode (i.e., a white background) [Default] and
``"dark"`` for dark mode (i.e., a darkgray background).
wordmark
Add the wordmark "PyGMT" and adjust its orientation relative to the visual.
Valid values are:

- ``"none"``: no wordmark [Default].
- ``"horizontal"``: wordmark at the right side of the visual.
- ``"vertical"``: wordmark below the visual.
color
``True`` for a color logo, and ``False`` for a black and white logo.
position
Position of the GMT logo on the plot. It can be specified in multiple ways:

- A :class:`pygmt.params.Position` object to fully control the reference point,
anchor point, and offset.
- A sequence of two values representing the x- and y-coordinates in plot
coordinates, e.g., ``(1, 2)`` or ``("1c", "2c")``.
- A :doc:`2-character justification code </techref/justification_codes>` for a
position inside the plot, e.g., ``"TL"`` for Top Left corner inside the plot.

If not specified, defaults to the Bottom Left corner of the plot (position
``(0, 0)`` with anchor ``"BL"``).
width
height
Width or height of the PyGMT logo. Since the aspect ratio is fixed, only one of
the two can be specified.
box
Draw a background box behind the logo. If set to ``True``, a simple rectangular
box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box appearance,
pass a :class:`pygmt.params.Box` object to control style, fill, pen, and other
box properties.
$verbose
$panel
$perspective
$transparency

Examples
--------
>>> import pygmt

The simplest way to plot the PyGMT logo is to call the method without any arguments.

>>> fig = pygmt.Figure()
>>> fig.pygmtlogo()
>>> fig.show()

Plot the PyGMT logo with the wordmark "PyGMT" with a height of 1 centimeter at the
right side in the Bottom Right corner on an existing basemap:

>>> fig = pygmt.Figure()
>>> fig.basemap(region=[-90, -70, 0, 20], projection="M10c", frame=True)
>>> fig.pygmtlogo(
... wordmark="horizontal",
... position="BR",
... height="1c",
... )
Comment thread
seisman marked this conversation as resolved.
>>> fig.show()
"""
with GMTTempFile(suffix=".eps") as logofile:
# Create logo file
_create_logo(
color=color,
theme=theme,
shape=shape,
wordmark=wordmark,
figname=logofile.name,
)

# Add to existing Figure instance
self.image(
imagefile=logofile.name,
position=position,
width=width,
height=height,
box=box,
verbose=verbose,
panel=panel,
Comment thread
yvonnefroehlich marked this conversation as resolved.
perspective=perspective,
transparency=transparency,
)
6 changes: 6 additions & 0 deletions pygmt/tests/baseline/test_pygmtlogo.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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?

hash: md5
path: test_pygmtlogo.png
Loading
Loading