From 2a319b73ea8a6e1e767ec876100efa2e80920bcc Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 13:06:02 +0100 Subject: [PATCH 001/379] Add first version of PyGMT code for PyGMT logo --- examples/gallery/embellishments/pygmt_logo.py | 263 ++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py new file mode 100755 index 00000000000..71ab3003c27 --- /dev/null +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -0,0 +1,263 @@ +""" +PyGMT logo +========== +The PyGMT logo coded in Python using PyGMT. The design of the logo is by +[@sfrooti](https://github.com/sfrooti). The logo consist of a visual and the wordmark +"PyGMT". There are different versions available: + +- ``color_concept``: colors of the visual and workmark. + Chose between ``"colors"`` to use the colors for Python (blue and yellow) and + GMT (red) and ``"bw"`` for black and white. +- ``bg_concept``: color of the background. + Chosse between ``"light"`` (white) and ``"dark"`` (darkgray / gray20). +- ``shape``: shape of the visual. + Choose between ``"circle"`` and ``"hexagon"``. +- ``angle_rot``: rotation angle of the visual (in degrees). +""" + +# %% +import pygmt + +# ----------------------------------------------------------------------------- +# Changebale settings (-> adjust for your needs; later input for function) +# ----------------------------------------------------------------------------- +color_concept = "color" # "color" | "bw" +bg_concept = "light" # "light" | "dark" +shape = "circle" # "circle" | "hexagon" +angle_rot = 30 # degrees +dpi_png = 720 # resolution of saved PNG image + + +# ----------------------------------------------------------------------------- +# Define colors (-> can be discussed) +# ----------------------------------------------------------------------------- +if color_concept == "color": + color_blue = "48/105/152" # Python blue + color_yellow = "255/212/59" # Python yellow + color_red = "238/86/52" # GMT red +elif color_concept == "bw" and bg_concept == "light": + color_blue = color_yellow = color_red = "gray20" +elif color_concept == "bw" and bg_concept == "dark": + color_blue = color_yellow = color_red = "white" + +match bg_concept: + case "light": + color_bg = "white" + color_py = color_blue + color_gmt = "gray20" + case "dark": + color_bg = "gray20" + color_py = color_yellow + color_gmt = "white" + + +# ----------------------------------------------------------------------------- +# Not-changebale settings (-> need to extended) +# ----------------------------------------------------------------------------- +size = 5 +region = [-size, size] * 2 + +xy_yellow_1 = 2.65 +xy_yellow_2 = 1.4 + +pen_yellow = f"5p,{color_yellow}" +pen_red = f"10p,{color_red}" + + +# %% + +# ----------------------------------------------------------------------------- +# Start plotting +# ----------------------------------------------------------------------------- + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Creating the visual +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +fig = pygmt.Figure() +pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") +fig.basemap( + region=region, projection=f"X{size * 2}c", frame=[0, "+gcyan@100"] +) # "a1f0.5g0.5" + +# ............................................................................. +# blue circle for Earth +# ............................................................................. +match shape: + case "circle": + style = "c7.5c" + case "hexagon": + style = "h8.6c" +fig.plot(x=0, y=0, style=style, pen=f"15p,{color_blue}", fill=color_bg) + +# ............................................................................. +# yellow lines for compass +# ............................................................................. +# horizontal yellow line +fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow) +# diagonal yellow lines +# upper left +fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow) +# lower right +fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], pen=pen_yellow) +# lower left +fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[-xy_yellow_1, -xy_yellow_2], pen=pen_yellow) +# upper right +fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], pen=pen_yellow) + +# ............................................................................. +# letter G +# ............................................................................. +# horizontal red line +fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}") +# red ring sector +fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red) +# space between yellow lines and ring sector +fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg) +# vertical yellow line +fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}") +# cover yellow line in lower part of the ring sector +fig.plot(x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red) + +# ............................................................................. +# upper vertical red line +# ............................................................................. +# space between red line and blue circle +fig.plot(x=[0, 0], y=[4.01, 3.0], pen=f"18p,{color_bg}") +# red line +fig.plot(x=[0, 0], y=[4.00, 1.9], pen=f"12p,{color_red}") + +# ............................................................................. +# letter M +# ............................................................................. +# space between letter M and yellow line at the right side +# fig.plot(x=[1.6, 1.6], y=[1.5, 1.8], pen=f"10p,{color_bg}") +fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}") +# diagonal lines +fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], pen=pen_red) +fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], pen=pen_red) +# middle pick +fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red) +# vertical lines +fig.plot(x=[0.285, 0.285], y=[0.00, 1.65], pen=pen_red) +fig.plot(x=[1.47, 1.47], y=[0.00, 1.65], pen=pen_red) + +# ............................................................................. +# letter T +# ............................................................................. +# red curved horizontal line +fig.plot(x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red) +# vertical endings of curved horizontal line +fig.plot(x=[-1.05, -1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}") +fig.plot(x=[1.05, 1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}") +# arrow head as inverse triangle +fig.plot(x=0, y=-3.55, style="i1.1c", fill=color_red, pen=f"3p,{color_bg}") +# arrow tail +fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}") + +# ............................................................................. +# Save +# ............................................................................. +# fig.show() +fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" +for ext in ["eps"]: + fig.savefig(fname=f"{fig_name}.{ext}", dpi=dpi_png) +print(fig_name) + + +# %% + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Replot and apply rotation (-> Get ride of the white margin; only transparent in PNG) +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +fig = pygmt.Figure() +pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") +fig.basemap(region=region, projection=f"X{size * 2}c", frame=[0, f"+g{color_bg}"]) + +fig.image( + imagefile=f"{fig_name}.eps", + position=f"jMC+w{size * 2}c", + # Rotation around z (vertical) axis placed in the center + perspective=f"{angle_rot}+w0/0", +) + +# ............................................................................. +# Save +# ............................................................................. +fig.show() +fig_name_rot = f"{fig_name}_rot{angle_rot}deg" +for ext in ["png", "eps"]: # , "pdf", "eps"]: + transparent = False + if ext == "png": + transparent = True + fig.savefig(fname=f"{fig_name_rot}.{ext}", dpi=dpi_png, transparent=transparent) +print(fig_name_rot) + + +# %% + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Replot and add WordMark "PyGMT" verticaly +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +fig = pygmt.Figure() +pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") +# pygmt.config(MAP_FRAME_PEN="1p,cyan") +fig.basemap( + region=region, + projection=f"X{size * 2 - 2}c/{size * 2}c", + frame=[0, f"+g{color_bg}"], +) + +fig.image(imagefile=f"{fig_name_rot}.eps", position=f"jMC+w{size * 2}c+o0c/1.1c") + +args_text = {"x": -3.6, "y": -3.6, "justify": "LM"} +fig.text(text="PyGMT", font=f"50p,AvantGarde-Book,{color_gmt}", **args_text) +fig.plot(x=-2.4, y=-3.6, style="s2.9c", fill=color_bg) +fig.text(text="Py", font=f"50p,AvantGarde-Book,{color_py}", **args_text) + +# ............................................................................. +# Save +# ............................................................................. +fig.show() +fig_name_rot_text = f"{fig_name_rot}_wordmark_vert" +for ext in ["png"]: # , "pdf", "eps"]: + transparent = False + if ext == "png": + transparent = True + fig.savefig( + fname=f"{fig_name_rot_text}.{ext}", dpi=dpi_png, transparent=transparent + ) +print(fig_name_rot_text) + + +# %% + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Replot and add WordMark "PyGMT" horizontaly +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +fig = pygmt.Figure() +pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") +# pygmt.config(MAP_FRAME_PEN="1p,cyan") +fig.basemap( + region=region, projection=f"X{size * 2}c/{size - 2}c", frame=[0, f"+g{color_bg}"] +) + +fig.image(imagefile=f"{fig_name_rot}.eps", position=f"jLM+w{size - 1.5}c") + +args_text = {"x": -1.5, "y": 0, "justify": "LM"} +fig.text(text="PyGMT", font=f"50p,AvantGarde-Book,{color_gmt}", **args_text) +fig.plot(x=-0.5, y=-0.2, style="s2.8c", fill=color_bg) +fig.text(text="Py", font=f"50p,AvantGarde-Book,{color_py}", **args_text) + +# ............................................................................. +# Save +# ............................................................................. +fig.show() +fig_name_rot_text = f"{fig_name_rot}_wordmark_hor" +for ext in ["png"]: # , "pdf", "eps"]: + transparent = False + if ext == "png": + transparent = True + fig.savefig( + fname=f"{fig_name_rot_text}.{ext}", dpi=dpi_png, transparent=transparent + ) +print(fig_name_rot_text) From c4e683f840b767b15bb20b17e02c461ee0ddd5ec Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 13:21:44 +0100 Subject: [PATCH 002/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 0eb9044ee31e7ccdb1ec59ac0509515917eca591 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 13:34:29 +0100 Subject: [PATCH 003/379] Adjust tumbnail image --- examples/gallery/embellishments/pygmt_logo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 71ab3003c27..3572ab42c14 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -261,3 +261,5 @@ fname=f"{fig_name_rot_text}.{ext}", dpi=dpi_png, transparent=transparent ) print(fig_name_rot_text) + +# sphinx_gallery_thumbnail_number = 3 From 4d2cc0e3778a8edbcb2f79cf72552c0cb53bd426 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 18:37:20 +0100 Subject: [PATCH 004/379] Introduce input variable for adding wordmark and adjusting the orientation --- examples/gallery/embellishments/pygmt_logo.py | 150 +++++++++--------- 1 file changed, 72 insertions(+), 78 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 3572ab42c14..b9cb5428d13 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -6,25 +6,40 @@ "PyGMT". There are different versions available: - ``color_concept``: colors of the visual and workmark. - Chose between ``"colors"`` to use the colors for Python (blue and yellow) and - GMT (red) and ``"bw"`` for black and white. + Select between ``"colors"`` (colors for Python (blue and yellow) and GMT (red)) and + ``"bw"`` for black and white. + [Default is ``"color"``]. - ``bg_concept``: color of the background. - Chosse between ``"light"`` (white) and ``"dark"`` (darkgray / gray20). + Select between ``"light"`` (white) and ``"dark"`` (darkgray / gray20). + [Default is ``"dark"``]. - ``shape``: shape of the visual. - Choose between ``"circle"`` and ``"hexagon"``. -- ``angle_rot``: rotation angle of the visual (in degrees). + Select between ``"circle"`` and ``"hexagon"``. + [Default is ``"circle"``]. +- ``angle_rot``: rotation angle of the visual. + Give an angle in degrees (mesuared contour-clockwise from the vertical). + [Default is ``30``]. Should this be flexible ??? +- ``wordmark``: add the wordmark "PyGMT". + ``True`` or ``False``. + [Default is ``True``]. ??? +- ``orientation``: orientation of the wordmark. + Select between ``"vertical"`` (at the bottom) and ``"horizontal"`` (at the right). + [Default is ``"vertical"``]. """ # %% +from pathlib import Path + import pygmt # ----------------------------------------------------------------------------- # Changebale settings (-> adjust for your needs; later input for function) # ----------------------------------------------------------------------------- color_concept = "color" # "color" | "bw" -bg_concept = "light" # "light" | "dark" +bg_concept = "dark" # "light" | "dark" shape = "circle" # "circle" | "hexagon" angle_rot = 30 # degrees +wordmark = True # True | False +orientation = "horizontal" # "horizontal" | "vertical" dpi_png = 720 # resolution of saved PNG image @@ -75,12 +90,11 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") -fig.basemap( - region=region, projection=f"X{size * 2}c", frame=[0, "+gcyan@100"] -) # "a1f0.5g0.5" +fig.basemap(region=region, projection=f"X{size * 2}c", frame=[0, "+gcyan@100"]) +# "a1f0.5g0.5" # ............................................................................. -# blue circle for Earth +# blue circle / hexagon for Earth # ............................................................................. match shape: case "circle": @@ -121,7 +135,7 @@ # ............................................................................. # upper vertical red line # ............................................................................. -# space between red line and blue circle +# space between red line and blue circle / hexagon fig.plot(x=[0, 0], y=[4.01, 3.0], pen=f"18p,{color_bg}") # red line fig.plot(x=[0, 0], y=[4.00, 1.9], pen=f"12p,{color_red}") @@ -149,13 +163,13 @@ # vertical endings of curved horizontal line fig.plot(x=[-1.05, -1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}") fig.plot(x=[1.05, 1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}") -# arrow head as inverse triangle +# arrow head as inverse triangle with pen for space to blue circle / hexagon fig.plot(x=0, y=-3.55, style="i1.1c", fill=color_red, pen=f"3p,{color_bg}") # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}") # ............................................................................. -# Save +# Save (-> Get ride of the white margin; only transparent in PNG) # ............................................................................. # fig.show() fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" @@ -167,7 +181,7 @@ # %% # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Replot and apply rotation (-> Get ride of the white margin; only transparent in PNG) +# Replot and apply rotation # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") @@ -183,9 +197,12 @@ # ............................................................................. # Save # ............................................................................. -fig.show() +# fig.show() fig_name_rot = f"{fig_name}_rot{angle_rot}deg" -for ext in ["png", "eps"]: # , "pdf", "eps"]: +exts = ["png"] +if wordmark is True: + exts = ["eps"] +for ext in exts: transparent = False if ext == "png": transparent = True @@ -196,70 +213,47 @@ # %% # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Replot and add WordMark "PyGMT" verticaly +# Replot and add WordMark "PyGMT" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -fig = pygmt.Figure() -pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") -# pygmt.config(MAP_FRAME_PEN="1p,cyan") -fig.basemap( - region=region, - projection=f"X{size * 2 - 2}c/{size * 2}c", - frame=[0, f"+g{color_bg}"], -) - -fig.image(imagefile=f"{fig_name_rot}.eps", position=f"jMC+w{size * 2}c+o0c/1.1c") - -args_text = {"x": -3.6, "y": -3.6, "justify": "LM"} -fig.text(text="PyGMT", font=f"50p,AvantGarde-Book,{color_gmt}", **args_text) -fig.plot(x=-2.4, y=-3.6, style="s2.9c", fill=color_bg) -fig.text(text="Py", font=f"50p,AvantGarde-Book,{color_py}", **args_text) - -# ............................................................................. -# Save -# ............................................................................. -fig.show() -fig_name_rot_text = f"{fig_name_rot}_wordmark_vert" -for ext in ["png"]: # , "pdf", "eps"]: - transparent = False - if ext == "png": - transparent = True - fig.savefig( - fname=f"{fig_name_rot_text}.{ext}", dpi=dpi_png, transparent=transparent - ) -print(fig_name_rot_text) +if wordmark is True: + match orientation: + case "vertical": + projection = f"X{size * 2 - 2}c/{size * 2}c" + position = f"jMC+w{size * 2}c+o0c/1.1c" + args_text = {"x": -3.6, "y": -3.6, "justify": "LM"} + args_cover = {"x": -2.4, "y": -3.6} + case "horizontal": + projection = f"X{size * 2}c/{size - 2}c" + position = f"jLM+w{size - 1.5}c" + args_text = {"x": -1.5, "y": 0, "justify": "LM"} + args_cover = {"x": -0.5, "y": -0.2} + + fig = pygmt.Figure() + pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") + # pygmt.config(MAP_FRAME_PEN="1p,cyan") + fig.basemap(region=region, projection=projection, frame=[0, f"+g{color_bg}"]) + + fig.image(imagefile=f"{fig_name_rot}.eps", position=position) + + fig.text(text="PyGMT", font=f"50p,AvantGarde-Book,{color_gmt}", **args_text) + fig.plot(style="s2.9c", fill=color_bg, **args_cover) + fig.text(text="Py", font=f"50p,AvantGarde-Book,{color_py}", **args_text) + + # ............................................................................. + # Save + # ............................................................................. + fig_name_rot_text = f"{fig_name_rot}_wordmark_{orientation}" + for ext in ["png"]: + transparent = False + if ext == "png": + transparent = True + fig.savefig( + fname=f"{fig_name_rot_text}.{ext}", dpi=dpi_png, transparent=transparent + ) + print(fig_name_rot_text) + Path.unlink(f"{fig_name_rot}.eps") # %% - -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Replot and add WordMark "PyGMT" horizontaly -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -fig = pygmt.Figure() -pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") -# pygmt.config(MAP_FRAME_PEN="1p,cyan") -fig.basemap( - region=region, projection=f"X{size * 2}c/{size - 2}c", frame=[0, f"+g{color_bg}"] -) - -fig.image(imagefile=f"{fig_name_rot}.eps", position=f"jLM+w{size - 1.5}c") - -args_text = {"x": -1.5, "y": 0, "justify": "LM"} -fig.text(text="PyGMT", font=f"50p,AvantGarde-Book,{color_gmt}", **args_text) -fig.plot(x=-0.5, y=-0.2, style="s2.8c", fill=color_bg) -fig.text(text="Py", font=f"50p,AvantGarde-Book,{color_py}", **args_text) - -# ............................................................................. -# Save -# ............................................................................. fig.show() -fig_name_rot_text = f"{fig_name_rot}_wordmark_hor" -for ext in ["png"]: # , "pdf", "eps"]: - transparent = False - if ext == "png": - transparent = True - fig.savefig( - fname=f"{fig_name_rot_text}.{ext}", dpi=dpi_png, transparent=transparent - ) -print(fig_name_rot_text) - -# sphinx_gallery_thumbnail_number = 3 +Path.unlink(f"{fig_name}.eps") From 7c10e4add2ccb4c01531e0e650cfc101d1e3ce3d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 18:43:19 +0100 Subject: [PATCH 005/379] Fix URL link --- examples/gallery/embellishments/pygmt_logo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index b9cb5428d13..2289e3c7e42 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -1,9 +1,9 @@ """ PyGMT logo ========== -The PyGMT logo coded in Python using PyGMT. The design of the logo is by -[@sfrooti](https://github.com/sfrooti). The logo consist of a visual and the wordmark -"PyGMT". There are different versions available: +The PyGMT logo coded in Python using PyGMT. The design of the logo is kindly provided +by `@sfrooti `_. The logo consists of a visual and the +wordmark "PyGMT". There are different versions available: - ``color_concept``: colors of the visual and workmark. Select between ``"colors"`` (colors for Python (blue and yellow) and GMT (red)) and From 135c4dccb008eb28f5b40ec5f17eceabcbe9c997 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 19:07:46 +0100 Subject: [PATCH 006/379] Adjust saving (temp) --- examples/gallery/embellishments/pygmt_logo.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 2289e3c7e42..55592c99cc6 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -169,12 +169,11 @@ fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}") # ............................................................................. -# Save (-> Get ride of the white margin; only transparent in PNG) +# Save # ............................................................................. # fig.show() fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" -for ext in ["eps"]: - fig.savefig(fname=f"{fig_name}.{ext}", dpi=dpi_png) +fig.savefig(fname=f"{fig_name}.eps", dpi=dpi_png) print(fig_name) @@ -199,10 +198,9 @@ # ............................................................................. # fig.show() fig_name_rot = f"{fig_name}_rot{angle_rot}deg" -exts = ["png"] -if wordmark is True: - exts = ["eps"] +exts = ["eps"] if wordmark is True else ["png", "pdf", "eps"] for ext in exts: + # transparent = True if ext == "png" else False # problems with code style transparent = False if ext == "png": transparent = True @@ -243,7 +241,8 @@ # Save # ............................................................................. fig_name_rot_text = f"{fig_name_rot}_wordmark_{orientation}" - for ext in ["png"]: + for ext in ["png", "pdf", "eps"]: + # transparent = True if ext == "png" else False # problems with code style transparent = False if ext == "png": transparent = True From 8c6df7a03884bf33023e4a13049c1f71ad46651a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 20:47:37 +0100 Subject: [PATCH 007/379] Adjust frame config --- examples/gallery/embellishments/pygmt_logo.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 55592c99cc6..c7c5d071714 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -89,9 +89,8 @@ # Creating the visual # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() -pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") +pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=region, projection=f"X{size * 2}c", frame=[0, "+gcyan@100"]) -# "a1f0.5g0.5" # ............................................................................. # blue circle / hexagon for Earth @@ -183,7 +182,7 @@ # Replot and apply rotation # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() -pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") +pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=region, projection=f"X{size * 2}c", frame=[0, f"+g{color_bg}"]) fig.image( @@ -227,8 +226,7 @@ args_cover = {"x": -0.5, "y": -0.2} fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN="0.01p,cyan@100") - # pygmt.config(MAP_FRAME_PEN="1p,cyan") + pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=region, projection=projection, frame=[0, f"+g{color_bg}"]) fig.image(imagefile=f"{fig_name_rot}.eps", position=position) From 11f230f111f81cf07e1c565943a97921754bf1f7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 21:18:53 +0100 Subject: [PATCH 008/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From dfd018a5cabe973083097b2781026893ccd9e69f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 23:30:45 +0100 Subject: [PATCH 009/379] Adjust length of diagonal lines --- examples/gallery/embellishments/pygmt_logo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index c7c5d071714..624e7c7d825 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -73,7 +73,7 @@ region = [-size, size] * 2 xy_yellow_1 = 2.65 -xy_yellow_2 = 1.4 +xy_yellow_2 = 1.3 pen_yellow = f"5p,{color_yellow}" pen_red = f"10p,{color_red}" @@ -143,7 +143,7 @@ # letter M # ............................................................................. # space between letter M and yellow line at the right side -# fig.plot(x=[1.6, 1.6], y=[1.5, 1.8], pen=f"10p,{color_bg}") +# fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}") # diagonal lines fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], pen=pen_red) From a9e0503b645fbc869c6a42e401c28ea4c8f3c829 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 23:31:42 +0100 Subject: [PATCH 010/379] Use corner for yellow line at right side of letter M --- examples/gallery/embellishments/pygmt_logo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 624e7c7d825..0186ea013e1 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -143,8 +143,8 @@ # letter M # ............................................................................. # space between letter M and yellow line at the right side -# fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") -fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}") +fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") +# fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}") # diagonal lines fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], pen=pen_red) fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], pen=pen_red) From c1679b326e0eec24f38e02756bcbae352362b9fa Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 23:32:19 +0100 Subject: [PATCH 011/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 58cad713f72b7e73a927b602a0ae195fbda0c25f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 13 Mar 2025 23:34:04 +0100 Subject: [PATCH 012/379] Add space between horizontal line of letter G and letter M Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/embellishments/pygmt_logo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 0186ea013e1..b2ae5364727 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -151,8 +151,8 @@ # middle pick fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red) # vertical lines -fig.plot(x=[0.285, 0.285], y=[0.00, 1.65], pen=pen_red) -fig.plot(x=[1.47, 1.47], y=[0.00, 1.65], pen=pen_red) +fig.plot(x=[0.285, 0.285], y=[0.30, 1.65], pen=pen_red) +fig.plot(x=[1.47, 1.47], y=[0.30, 1.65], pen=pen_red) # ............................................................................. # letter T From eb9c3172e8d3271eca987c27171f7d0cfc3e7368 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 23:35:50 +0100 Subject: [PATCH 013/379] Add comment for distance between letters M and G --- examples/gallery/embellishments/pygmt_logo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index b2ae5364727..24fc80b81d0 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -150,7 +150,7 @@ fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], pen=pen_red) # middle pick fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red) -# vertical lines +# vertical lines with small distance to horizontal line of letter G fig.plot(x=[0.285, 0.285], y=[0.30, 1.65], pen=pen_red) fig.plot(x=[1.47, 1.47], y=[0.30, 1.65], pen=pen_red) From 5cc808e482a12720c11adc484676fc423205d67a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 09:22:56 +0100 Subject: [PATCH 014/379] Reduce white margin --- examples/gallery/embellishments/pygmt_logo.py | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 24fc80b81d0..e59a7423817 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -69,7 +69,7 @@ # ----------------------------------------------------------------------------- # Not-changebale settings (-> need to extended) # ----------------------------------------------------------------------------- -size = 5 +size = 4 region = [-size, size] * 2 xy_yellow_1 = 2.65 @@ -100,13 +100,13 @@ style = "c7.5c" case "hexagon": style = "h8.6c" -fig.plot(x=0, y=0, style=style, pen=f"15p,{color_blue}", fill=color_bg) +fig.plot(x=0, y=0, style=style, pen=f"15p,{color_blue}", fill=color_bg, no_clip=True) # ............................................................................. # yellow lines for compass # ............................................................................. # horizontal yellow line -fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow) +fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow, no_clip=True) # diagonal yellow lines # upper left fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow) @@ -170,9 +170,10 @@ # ............................................................................. # Save # ............................................................................. -# fig.show() +fig.show() fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" -fig.savefig(fname=f"{fig_name}.eps", dpi=dpi_png) +fig.savefig(fname=f"{fig_name}.eps") +# fig.savefig(fname=f"{fig_name}.png", dpi=dpi_png, transparent=True) print(fig_name) @@ -183,7 +184,9 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") -fig.basemap(region=region, projection=f"X{size * 2}c", frame=[0, f"+g{color_bg}"]) +fig.basemap( + region=region, projection=f"X{(size + 0.1) * 2}c", frame=[0, f"+g{color_bg}"] +) fig.image( imagefile=f"{fig_name}.eps", @@ -195,7 +198,7 @@ # ............................................................................. # Save # ............................................................................. -# fig.show() +fig.show() fig_name_rot = f"{fig_name}_rot{angle_rot}deg" exts = ["eps"] if wordmark is True else ["png", "pdf", "eps"] for ext in exts: @@ -213,17 +216,18 @@ # Replot and add WordMark "PyGMT" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if wordmark is True: + size = 4 match orientation: case "vertical": - projection = f"X{size * 2 - 2}c/{size * 2}c" - position = f"jMC+w{size * 2}c+o0c/1.1c" - args_text = {"x": -3.6, "y": -3.6, "justify": "LM"} - args_cover = {"x": -2.4, "y": -3.6} + projection = f"X{size * 2 - 1.5}c/{size * 2}c" + position = f"jMC+w{size * 2 - 1.5}c+o0c/0.9c" + args_text = {"x": -3.2, "y": -2.8, "justify": "LM"} + args_cover = {"x": -2.2, "y": -2.8} case "horizontal": projection = f"X{size * 2}c/{size - 2}c" - position = f"jLM+w{size - 1.5}c" - args_text = {"x": -1.5, "y": 0, "justify": "LM"} - args_cover = {"x": -0.5, "y": -0.2} + position = f"jLM+w{size - 2}c" + args_text = {"x": -1.6, "y": 0, "justify": "LM"} + args_cover = {"x": -0.7, "y": 0} fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") @@ -231,9 +235,9 @@ fig.image(imagefile=f"{fig_name_rot}.eps", position=position) - fig.text(text="PyGMT", font=f"50p,AvantGarde-Book,{color_gmt}", **args_text) - fig.plot(style="s2.9c", fill=color_bg, **args_cover) - fig.text(text="Py", font=f"50p,AvantGarde-Book,{color_py}", **args_text) + fig.text(text="PyGMT", font=f"45p,AvantGarde-Book,{color_gmt}", **args_text) + fig.plot(style="s2.6c", fill=color_bg, **args_cover) + fig.text(text="Py", font=f"45p,AvantGarde-Book,{color_py}", **args_text) # ............................................................................. # Save From cdadee3a167c8e36cdf817f7623ea31f76b3b6e4 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 09:23:16 +0100 Subject: [PATCH 015/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 6b910610308293515dee57fa566f3c895c002eb1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 09:40:51 +0100 Subject: [PATCH 016/379] Add transparent option --- examples/gallery/embellishments/pygmt_logo.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index e59a7423817..3028b2aa664 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -15,15 +15,18 @@ - ``shape``: shape of the visual. Select between ``"circle"`` and ``"hexagon"``. [Default is ``"circle"``]. -- ``angle_rot``: rotation angle of the visual. - Give an angle in degrees (mesuared contour-clockwise from the vertical). - [Default is ``30``]. Should this be flexible ??? - ``wordmark``: add the wordmark "PyGMT". ``True`` or ``False``. [Default is ``True``]. ??? - ``orientation``: orientation of the wordmark. Select between ``"vertical"`` (at the bottom) and ``"horizontal"`` (at the right). [Default is ``"vertical"``]. +- ``bg_transparent``: make visual transparent outside of the circle or hexagon. + ``True`` or ``False``. Only available for PNG output. + [Default is ``False``]. +- ``angle_rot``: rotation angle of the visual. + Give an angle in degrees (mesuared contour-clockwise from the vertical). + [Default is ``30``]. Should this be flexible ??? """ # %% @@ -36,10 +39,12 @@ # ----------------------------------------------------------------------------- color_concept = "color" # "color" | "bw" bg_concept = "dark" # "light" | "dark" -shape = "circle" # "circle" | "hexagon" -angle_rot = 30 # degrees +shape = "hexagon" # "circle" | "hexagon" wordmark = True # True | False orientation = "horizontal" # "horizontal" | "vertical" +bg_transparent = True # True | False + +angle_rot = 30 # degrees dpi_png = 720 # resolution of saved PNG image @@ -184,8 +189,10 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") + +bg_alpha = 100 if bg_transparent is True else 0 fig.basemap( - region=region, projection=f"X{(size + 0.1) * 2}c", frame=[0, f"+g{color_bg}"] + region=region, projection=f"X{(size + 0.1) * 2}c", frame=f"+g{color_bg}@{bg_alpha}" ) fig.image( From 6a2e785ca718670b673879a31df0b98e01686c57 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 09:41:24 +0100 Subject: [PATCH 017/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 9bbf4433de59d18f9d8435a55b993619d9eecc99 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 09:43:03 +0100 Subject: [PATCH 018/379] Adjust yellow line ending at the right side of letter M --- examples/gallery/embellishments/pygmt_logo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 3028b2aa664..2317e616d3b --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -148,8 +148,8 @@ # letter M # ............................................................................. # space between letter M and yellow line at the right side -fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") -# fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}") +# fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") +fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}") # diagonal lines fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], pen=pen_red) fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], pen=pen_red) From 0aea0b0dd0290af2d334b3cb3cfae7d664d7881b Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 11:49:03 +0100 Subject: [PATCH 019/379] Make clean border of shape --- examples/gallery/embellishments/pygmt_logo.py | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 2317e616d3b..a6bb68e3a4b 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -39,15 +39,14 @@ # ----------------------------------------------------------------------------- color_concept = "color" # "color" | "bw" bg_concept = "dark" # "light" | "dark" -shape = "hexagon" # "circle" | "hexagon" +shape = "circle" # "circle" | "hexagon" wordmark = True # True | False orientation = "horizontal" # "horizontal" | "vertical" -bg_transparent = True # True | False +bg_transparent = False # True | False angle_rot = 30 # degrees dpi_png = 720 # resolution of saved PNG image - # ----------------------------------------------------------------------------- # Define colors (-> can be discussed) # ----------------------------------------------------------------------------- @@ -70,7 +69,6 @@ color_py = color_yellow color_gmt = "white" - # ----------------------------------------------------------------------------- # Not-changebale settings (-> need to extended) # ----------------------------------------------------------------------------- @@ -83,7 +81,6 @@ pen_yellow = f"5p,{color_yellow}" pen_red = f"10p,{color_red}" - # %% # ----------------------------------------------------------------------------- @@ -102,10 +99,21 @@ # ............................................................................. match shape: case "circle": - style = "c7.5c" + diameter = 7.5 + diameter_add = 0.5 + symbol = "c" case "hexagon": - style = "h8.6c" -fig.plot(x=0, y=0, style=style, pen=f"15p,{color_blue}", fill=color_bg, no_clip=True) + diameter = 8.6 + diameter_add = 0.6 + symbol = "h" +fig.plot( + x=0, + y=0, + style=f"{symbol}{diameter}c", + pen=f"15p,{color_blue}", + fill=color_bg, + no_clip=True, +) # ............................................................................. # yellow lines for compass @@ -140,9 +148,9 @@ # upper vertical red line # ............................................................................. # space between red line and blue circle / hexagon -fig.plot(x=[0, 0], y=[4.01, 3.0], pen=f"18p,{color_bg}") +fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}") # red line -fig.plot(x=[0, 0], y=[4.00, 1.9], pen=f"12p,{color_red}") +fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}") # ............................................................................. # letter M @@ -172,16 +180,26 @@ # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}") +# margin around shape with slight overplotting for clean borders +color_margin = color_bg +if color_concept == "color" and bg_transparent and not wordmark: + color_margin = "white" +fig.plot( + x=0, + y=0, + style=f"{symbol}{diameter + diameter_add}c", + pen=f"1p,{color_margin}", + no_clip=True, +) + # ............................................................................. # Save # ............................................................................. fig.show() fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" fig.savefig(fname=f"{fig_name}.eps") -# fig.savefig(fname=f"{fig_name}.png", dpi=dpi_png, transparent=True) print(fig_name) - # %% # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -191,9 +209,7 @@ pygmt.config(MAP_FRAME_PEN="cyan@100") bg_alpha = 100 if bg_transparent is True else 0 -fig.basemap( - region=region, projection=f"X{(size + 0.1) * 2}c", frame=f"+g{color_bg}@{bg_alpha}" -) +fig.basemap(region=region, projection=f"X{size * 2}c", frame=f"+g{color_bg}@{bg_alpha}") fig.image( imagefile=f"{fig_name}.eps", @@ -216,7 +232,6 @@ fig.savefig(fname=f"{fig_name_rot}.{ext}", dpi=dpi_png, transparent=transparent) print(fig_name_rot) - # %% # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -261,7 +276,6 @@ print(fig_name_rot_text) Path.unlink(f"{fig_name_rot}.eps") - # %% fig.show() Path.unlink(f"{fig_name}.eps") From 80b9a486824e730ed570d2d02e0f378fe8edd4e3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 11:49:25 +0100 Subject: [PATCH 020/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 591f7244b613b15285a86797fba1f50c3868ebcd Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 12:48:25 +0100 Subject: [PATCH 021/379] Subpress temporary show | Add frame 0 --- examples/gallery/embellishments/pygmt_logo.py | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index a6bb68e3a4b..dde12fc1637 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -38,10 +38,10 @@ # Changebale settings (-> adjust for your needs; later input for function) # ----------------------------------------------------------------------------- color_concept = "color" # "color" | "bw" -bg_concept = "dark" # "light" | "dark" +bg_concept = "light" # "light" | "dark" shape = "circle" # "circle" | "hexagon" wordmark = True # True | False -orientation = "horizontal" # "horizontal" | "vertical" +orientation = "vertical" # "horizontal" | "vertical" bg_transparent = False # True | False angle_rot = 30 # degrees @@ -195,7 +195,7 @@ # ............................................................................. # Save # ............................................................................. -fig.show() +# fig.show() fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" fig.savefig(fname=f"{fig_name}.eps") print(fig_name) @@ -209,7 +209,9 @@ pygmt.config(MAP_FRAME_PEN="cyan@100") bg_alpha = 100 if bg_transparent is True else 0 -fig.basemap(region=region, projection=f"X{size * 2}c", frame=f"+g{color_bg}@{bg_alpha}") +fig.basemap( + region=region, projection=f"X{size * 2}c", frame=[0, f"+g{color_bg}@{bg_alpha}"] +) fig.image( imagefile=f"{fig_name}.eps", @@ -221,24 +223,23 @@ # ............................................................................. # Save # ............................................................................. -fig.show() +# fig.show() fig_name_rot = f"{fig_name}_rot{angle_rot}deg" exts = ["eps"] if wordmark is True else ["png", "pdf", "eps"] for ext in exts: - # transparent = True if ext == "png" else False # problems with code style - transparent = False + # alpha_png = True if ext == "png" else False # problems with code style + alpha_png = False if ext == "png": - transparent = True - fig.savefig(fname=f"{fig_name_rot}.{ext}", dpi=dpi_png, transparent=transparent) + alpha_png = True + fig.savefig(fname=f"{fig_name_rot}.{ext}", dpi=dpi_png, transparent=alpha_png) print(fig_name_rot) # %% # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Replot and add WordMark "PyGMT" +# Replot and add wordmark "PyGMT" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if wordmark is True: - size = 4 match orientation: case "vertical": projection = f"X{size * 2 - 1.5}c/{size * 2}c" @@ -267,11 +268,11 @@ fig_name_rot_text = f"{fig_name_rot}_wordmark_{orientation}" for ext in ["png", "pdf", "eps"]: # transparent = True if ext == "png" else False # problems with code style - transparent = False + alpha_png = False if ext == "png": - transparent = True + alpha_png = True fig.savefig( - fname=f"{fig_name_rot_text}.{ext}", dpi=dpi_png, transparent=transparent + fname=f"{fig_name_rot_text}.{ext}", dpi=dpi_png, transparent=alpha_png ) print(fig_name_rot_text) Path.unlink(f"{fig_name_rot}.eps") From c75397db872a701d9609fba8c55c8fd9e73c7c9e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 12:48:47 +0100 Subject: [PATCH 022/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 1fbb0906d8e7e8ea1b1187b1a31a601c64be8df8 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 15:39:39 +0100 Subject: [PATCH 023/379] Introduce box parameter --- examples/gallery/embellishments/pygmt_logo.py | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index dde12fc1637..6a943b05e37 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -22,7 +22,12 @@ Select between ``"vertical"`` (at the bottom) and ``"horizontal"`` (at the right). [Default is ``"vertical"``]. - ``bg_transparent``: make visual transparent outside of the circle or hexagon. - ``True`` or ``False``. Only available for PNG output. + ``True`` or ``False``. + Only available for PNG format. Not supported for adding a wordmark. + [Default is ``False``]. +- ``box``: add a box around the logo. + ``True`` or ``False``. + Mainly relevant for ``bg_concept = "light"``. [Default is ``False``]. - ``angle_rot``: rotation angle of the visual. Give an angle in degrees (mesuared contour-clockwise from the vertical). @@ -34,6 +39,7 @@ import pygmt + # ----------------------------------------------------------------------------- # Changebale settings (-> adjust for your needs; later input for function) # ----------------------------------------------------------------------------- @@ -42,7 +48,8 @@ shape = "circle" # "circle" | "hexagon" wordmark = True # True | False orientation = "vertical" # "horizontal" | "vertical" -bg_transparent = False # True | False +bg_transparent = True # True | False +box = True, # True | False angle_rot = 30 # degrees dpi_png = 720 # resolution of saved PNG image @@ -122,11 +129,17 @@ fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow, no_clip=True) # diagonal yellow lines # upper left -fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow) +fig.plot( + x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow +) # lower right -fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], pen=pen_yellow) +fig.plot( + x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], pen=pen_yellow +) # lower left -fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[-xy_yellow_1, -xy_yellow_2], pen=pen_yellow) +fig.plot( + x=[-xy_yellow_1, -xy_yellow_2], y=[-xy_yellow_1, -xy_yellow_2], pen=pen_yellow +) # upper right fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], pen=pen_yellow) @@ -206,7 +219,10 @@ # Replot and apply rotation # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() -pygmt.config(MAP_FRAME_PEN="cyan@100") +frame_pen = "cyan@100" +if box == True and wordmark == False: + frame_pen = "0.5p,gray20" +pygmt.config(MAP_FRAME_PEN=frame_pen) bg_alpha = 100 if bg_transparent is True else 0 fig.basemap( @@ -253,7 +269,8 @@ args_cover = {"x": -0.7, "y": 0} fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN="cyan@100") + frame_pen = "cyan@100" if box == True else "0.5p,gray20" + pygmt.config(MAP_FRAME_PEN=frame_pen) fig.basemap(region=region, projection=projection, frame=[0, f"+g{color_bg}"]) fig.image(imagefile=f"{fig_name_rot}.eps", position=position) From b1d373ad6f2436be27b8c2a9255d200a771a362c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 15:46:57 +0100 Subject: [PATCH 024/379] Fix code style | Improve box querry --- examples/gallery/embellishments/pygmt_logo.py | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 6a943b05e37..d5594071eda 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -39,7 +39,6 @@ import pygmt - # ----------------------------------------------------------------------------- # Changebale settings (-> adjust for your needs; later input for function) # ----------------------------------------------------------------------------- @@ -49,7 +48,7 @@ wordmark = True # True | False orientation = "vertical" # "horizontal" | "vertical" bg_transparent = True # True | False -box = True, # True | False +box = True # True | False angle_rot = 30 # degrees dpi_png = 720 # resolution of saved PNG image @@ -129,17 +128,11 @@ fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow, no_clip=True) # diagonal yellow lines # upper left -fig.plot( - x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow -) +fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow) # lower right -fig.plot( - x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], pen=pen_yellow -) +fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], pen=pen_yellow) # lower left -fig.plot( - x=[-xy_yellow_1, -xy_yellow_2], y=[-xy_yellow_1, -xy_yellow_2], pen=pen_yellow -) +fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[-xy_yellow_1, -xy_yellow_2], pen=pen_yellow) # upper right fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], pen=pen_yellow) @@ -219,9 +212,7 @@ # Replot and apply rotation # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() -frame_pen = "cyan@100" -if box == True and wordmark == False: - frame_pen = "0.5p,gray20" +frame_pen = "0.5p,gray20" if box and not wordmark else "cyan@100" pygmt.config(MAP_FRAME_PEN=frame_pen) bg_alpha = 100 if bg_transparent is True else 0 @@ -269,7 +260,7 @@ args_cover = {"x": -0.7, "y": 0} fig = pygmt.Figure() - frame_pen = "cyan@100" if box == True else "0.5p,gray20" + frame_pen = "0.5p,gray20" if box else "cyan@100" pygmt.config(MAP_FRAME_PEN=frame_pen) fig.basemap(region=region, projection=projection, frame=[0, f"+g{color_bg}"]) From 39e5ba1571eba49e900b1d927048014af03955b2 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 15:49:02 +0100 Subject: [PATCH 025/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 8519275d64fb6563e025fa3e95b775150fef10c5 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 16:06:51 +0100 Subject: [PATCH 026/379] Update variable name --- examples/gallery/embellishments/pygmt_logo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index d5594071eda..808b93ef102 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -275,7 +275,7 @@ # ............................................................................. fig_name_rot_text = f"{fig_name_rot}_wordmark_{orientation}" for ext in ["png", "pdf", "eps"]: - # transparent = True if ext == "png" else False # problems with code style + # alpha_png = True if ext == "png" else False # problems with code style alpha_png = False if ext == "png": alpha_png = True From 71185eedf7589de78614dd273855764e7e8ee714 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 16:07:12 +0100 Subject: [PATCH 027/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 57d91bd49e4060a1e7685aabf03acdb88c6fceaa Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 17:23:34 +0100 Subject: [PATCH 028/379] Convert to function --- examples/gallery/embellishments/pygmt_logo.py | 496 +++++++++--------- 1 file changed, 261 insertions(+), 235 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 808b93ef102..684407b9ff3 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -17,7 +17,7 @@ [Default is ``"circle"``]. - ``wordmark``: add the wordmark "PyGMT". ``True`` or ``False``. - [Default is ``True``]. ??? + [Default is ``True``]. - ``orientation``: orientation of the wordmark. Select between ``"vertical"`` (at the bottom) and ``"horizontal"`` (at the right). [Default is ``"vertical"``]. @@ -29,9 +29,6 @@ ``True`` or ``False``. Mainly relevant for ``bg_concept = "light"``. [Default is ``False``]. -- ``angle_rot``: rotation angle of the visual. - Give an angle in degrees (mesuared contour-clockwise from the vertical). - [Default is ``30``]. Should this be flexible ??? """ # %% @@ -42,249 +39,278 @@ # ----------------------------------------------------------------------------- # Changebale settings (-> adjust for your needs; later input for function) # ----------------------------------------------------------------------------- -color_concept = "color" # "color" | "bw" -bg_concept = "light" # "light" | "dark" -shape = "circle" # "circle" | "hexagon" -wordmark = True # True | False -orientation = "vertical" # "horizontal" | "vertical" -bg_transparent = True # True | False -box = True # True | False +def pygmtlogo( + color_concept="color", # "color" | "bw" + bg_concept="dark", # "light" | "dark" + shape="circle", # "circle" | "hexagon" + wordmark=True, # True | False + orientation="horizontal", # "horizontal" | "vertical" + bg_transparent=False, # True | False + box=False, # True | False # TODO use box parameter of Figure.image + position="jRT+o0.1c+w4c", +): + + def create_logo( + color_concept=color_concept, + bg_concept=bg_concept, + shape=shape, + wordmark=wordmark, + orientation=orientation, + bg_transparent=bg_transparent, + box=box, + ): + + # ----------------------------------------------------------------------------- + # Define colors (-> can be discussed) + # ----------------------------------------------------------------------------- + if color_concept == "color": + color_blue = "48/105/152" # Python blue + color_yellow = "255/212/59" # Python yellow + color_red = "238/86/52" # GMT red + elif color_concept == "bw" and bg_concept == "light": + color_blue = color_yellow = color_red = "gray20" + elif color_concept == "bw" and bg_concept == "dark": + color_blue = color_yellow = color_red = "white" + + match bg_concept: + case "light": + color_bg = "white" + color_py = color_blue + color_gmt = "gray20" + case "dark": + color_bg = "gray20" + color_py = color_yellow + color_gmt = "white" + + # ----------------------------------------------------------------------------- + # Not-changebale settings (-> need to extended) + # ----------------------------------------------------------------------------- + size = 4 + region = [-size, size] * 2 + + xy_yellow_1 = 2.65 + xy_yellow_2 = 1.3 + + pen_yellow = f"5p,{color_yellow}" + pen_red = f"10p,{color_red}" + + angle_rot = 30 # degrees + + # %% + + # ----------------------------------------------------------------------------- + # Start plotting + # ----------------------------------------------------------------------------- + + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # Creating the visual + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + fig = pygmt.Figure() + pygmt.config(MAP_FRAME_PEN="cyan@100") + fig.basemap(region=region, projection=f"X{size * 2}c", frame=[0, "+gcyan@100"]) + + # ............................................................................. + # blue circle / hexagon for Earth + # ............................................................................. + match shape: + case "circle": + diameter = 7.5 + diameter_add = 0.5 + symbol = "c" + case "hexagon": + diameter = 8.6 + diameter_add = 0.6 + symbol = "h" + fig.plot( + x=0, + y=0, + style=f"{symbol}{diameter}c", + pen=f"15p,{color_blue}", + fill=color_bg, + no_clip=True, + ) -angle_rot = 30 # degrees -dpi_png = 720 # resolution of saved PNG image + # ............................................................................. + # yellow lines for compass + # ............................................................................. + # horizontal yellow line + fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow, no_clip=True) + # diagonal yellow lines + # upper left + fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow) + # lower right + fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], pen=pen_yellow) + # lower left + fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[-xy_yellow_1, -xy_yellow_2], pen=pen_yellow) + # upper right + fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], pen=pen_yellow) + + # ............................................................................. + # letter G + # ............................................................................. + # horizontal red line + fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}") + # red ring sector + fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red) + # space between yellow lines and ring sector + fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg) + # vertical yellow line + fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}") + # cover yellow line in lower part of the ring sector + fig.plot(x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red) + + # ............................................................................. + # upper vertical red line + # ............................................................................. + # space between red line and blue circle / hexagon + fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}") + # red line + fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}") + + # ............................................................................. + # letter M + # ............................................................................. + # space between letter M and yellow line at the right side + # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") + fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}") + # diagonal lines + fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], pen=pen_red) + fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], pen=pen_red) + # middle pick + fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red) + # vertical lines with small distance to horizontal line of letter G + fig.plot(x=[0.285, 0.285], y=[0.30, 1.65], pen=pen_red) + fig.plot(x=[1.47, 1.47], y=[0.30, 1.65], pen=pen_red) + + # ............................................................................. + # letter T + # ............................................................................. + # red curved horizontal line + fig.plot(x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red) + # vertical endings of curved horizontal line + fig.plot(x=[-1.05, -1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}") + fig.plot(x=[1.05, 1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}") + # arrow head as inverse triangle with pen for space to blue circle / hexagon + fig.plot(x=0, y=-3.55, style="i1.1c", fill=color_red, pen=f"3p,{color_bg}") + # arrow tail + fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}") + + # margin around shape with slight overplotting for clean borders + color_margin = color_bg + if color_concept == "color" and bg_transparent and not wordmark: + color_margin = "white" + fig.plot( + x=0, + y=0, + style=f"{symbol}{diameter + diameter_add}c", + pen=f"1p,{color_margin}", + no_clip=True, + ) -# ----------------------------------------------------------------------------- -# Define colors (-> can be discussed) -# ----------------------------------------------------------------------------- -if color_concept == "color": - color_blue = "48/105/152" # Python blue - color_yellow = "255/212/59" # Python yellow - color_red = "238/86/52" # GMT red -elif color_concept == "bw" and bg_concept == "light": - color_blue = color_yellow = color_red = "gray20" -elif color_concept == "bw" and bg_concept == "dark": - color_blue = color_yellow = color_red = "white" - -match bg_concept: - case "light": - color_bg = "white" - color_py = color_blue - color_gmt = "gray20" - case "dark": - color_bg = "gray20" - color_py = color_yellow - color_gmt = "white" + # ............................................................................. + # Save + # ............................................................................. + # fig.show() + fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" + fig.savefig(fname=f"{fig_name}.eps") + print(fig_name) + + # %% + + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # Replot and apply rotation + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + fig = pygmt.Figure() + frame_pen = "0.5p,gray20" if box and not wordmark else "cyan@100" + pygmt.config(MAP_FRAME_PEN=frame_pen) + + bg_alpha = 100 if bg_transparent is True else 0 + fig.basemap( + region=region, projection=f"X{size * 2}c", frame=[0, f"+g{color_bg}@{bg_alpha}"] + ) -# ----------------------------------------------------------------------------- -# Not-changebale settings (-> need to extended) -# ----------------------------------------------------------------------------- -size = 4 -region = [-size, size] * 2 + fig.image( + imagefile=f"{fig_name}.eps", + position=f"jMC+w{size * 2}c", + # Rotation around z (vertical) axis placed in the center + perspective=f"{angle_rot}+w0/0", + ) -xy_yellow_1 = 2.65 -xy_yellow_2 = 1.3 + # ............................................................................. + # Save + # ............................................................................. + # fig.show() + fig_name_rot = fig_name_logo = f"{fig_name}_rot{angle_rot}deg" + fig.savefig(fname=f"{fig_name_rot}.eps") + print(fig_name_rot) -pen_yellow = f"5p,{color_yellow}" -pen_red = f"10p,{color_red}" + # %% -# %% + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # Replot and add wordmark "PyGMT" + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if wordmark is True: + match orientation: + case "vertical": + projection = f"X{size * 2 - 1.5}c/{size * 2}c" + position = f"jMC+w{size * 2 - 1.5}c+o0c/0.9c" + args_text = {"x": -3.2, "y": -2.8, "justify": "LM"} + args_cover = {"x": -2.2, "y": -2.8} + case "horizontal": + projection = f"X{size * 2}c/{size - 2}c" + position = f"jLM+w{size - 2}c" + args_text = {"x": -1.6, "y": 0, "justify": "LM"} + args_cover = {"x": -0.7, "y": 0} -# ----------------------------------------------------------------------------- -# Start plotting -# ----------------------------------------------------------------------------- + fig = pygmt.Figure() + frame_pen = "0.5p,gray20" if box else "cyan@100" + pygmt.config(MAP_FRAME_PEN=frame_pen) + fig.basemap(region=region, projection=projection, frame=[0, f"+g{color_bg}"]) -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Creating the visual -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -fig = pygmt.Figure() -pygmt.config(MAP_FRAME_PEN="cyan@100") -fig.basemap(region=region, projection=f"X{size * 2}c", frame=[0, "+gcyan@100"]) - -# ............................................................................. -# blue circle / hexagon for Earth -# ............................................................................. -match shape: - case "circle": - diameter = 7.5 - diameter_add = 0.5 - symbol = "c" - case "hexagon": - diameter = 8.6 - diameter_add = 0.6 - symbol = "h" -fig.plot( - x=0, - y=0, - style=f"{symbol}{diameter}c", - pen=f"15p,{color_blue}", - fill=color_bg, - no_clip=True, -) - -# ............................................................................. -# yellow lines for compass -# ............................................................................. -# horizontal yellow line -fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow, no_clip=True) -# diagonal yellow lines -# upper left -fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow) -# lower right -fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], pen=pen_yellow) -# lower left -fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[-xy_yellow_1, -xy_yellow_2], pen=pen_yellow) -# upper right -fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], pen=pen_yellow) - -# ............................................................................. -# letter G -# ............................................................................. -# horizontal red line -fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}") -# red ring sector -fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red) -# space between yellow lines and ring sector -fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg) -# vertical yellow line -fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}") -# cover yellow line in lower part of the ring sector -fig.plot(x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red) - -# ............................................................................. -# upper vertical red line -# ............................................................................. -# space between red line and blue circle / hexagon -fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}") -# red line -fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}") - -# ............................................................................. -# letter M -# ............................................................................. -# space between letter M and yellow line at the right side -# fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") -fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}") -# diagonal lines -fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], pen=pen_red) -fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], pen=pen_red) -# middle pick -fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red) -# vertical lines with small distance to horizontal line of letter G -fig.plot(x=[0.285, 0.285], y=[0.30, 1.65], pen=pen_red) -fig.plot(x=[1.47, 1.47], y=[0.30, 1.65], pen=pen_red) - -# ............................................................................. -# letter T -# ............................................................................. -# red curved horizontal line -fig.plot(x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red) -# vertical endings of curved horizontal line -fig.plot(x=[-1.05, -1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}") -fig.plot(x=[1.05, 1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}") -# arrow head as inverse triangle with pen for space to blue circle / hexagon -fig.plot(x=0, y=-3.55, style="i1.1c", fill=color_red, pen=f"3p,{color_bg}") -# arrow tail -fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}") - -# margin around shape with slight overplotting for clean borders -color_margin = color_bg -if color_concept == "color" and bg_transparent and not wordmark: - color_margin = "white" -fig.plot( - x=0, - y=0, - style=f"{symbol}{diameter + diameter_add}c", - pen=f"1p,{color_margin}", - no_clip=True, -) - -# ............................................................................. -# Save -# ............................................................................. -# fig.show() -fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" -fig.savefig(fname=f"{fig_name}.eps") -print(fig_name) + fig.image(imagefile=f"{fig_name_rot}.eps", position=position) -# %% + fig.text(text="PyGMT", font=f"45p,AvantGarde-Book,{color_gmt}", **args_text) + fig.plot(style="s2.6c", fill=color_bg, **args_cover) + fig.text(text="Py", font=f"45p,AvantGarde-Book,{color_py}", **args_text) -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Replot and apply rotation -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -fig = pygmt.Figure() -frame_pen = "0.5p,gray20" if box and not wordmark else "cyan@100" -pygmt.config(MAP_FRAME_PEN=frame_pen) - -bg_alpha = 100 if bg_transparent is True else 0 -fig.basemap( - region=region, projection=f"X{size * 2}c", frame=[0, f"+g{color_bg}@{bg_alpha}"] -) - -fig.image( - imagefile=f"{fig_name}.eps", - position=f"jMC+w{size * 2}c", - # Rotation around z (vertical) axis placed in the center - perspective=f"{angle_rot}+w0/0", -) - -# ............................................................................. -# Save -# ............................................................................. -# fig.show() -fig_name_rot = f"{fig_name}_rot{angle_rot}deg" -exts = ["eps"] if wordmark is True else ["png", "pdf", "eps"] -for ext in exts: - # alpha_png = True if ext == "png" else False # problems with code style - alpha_png = False - if ext == "png": - alpha_png = True - fig.savefig(fname=f"{fig_name_rot}.{ext}", dpi=dpi_png, transparent=alpha_png) -print(fig_name_rot) + # ............................................................................. + # Save + # ............................................................................. + fig_name_rot_text = fig_name_logo = f"{fig_name_rot}_wordmark_{orientation}" + fig.savefig(fname=f"{fig_name_rot_text}.eps") + print(fig_name_rot_text) + Path.unlink(f"{fig_name_rot}.eps") + + # %% + # fig.show() + Path.unlink(f"{fig_name}.eps") + + return fig_name_logo + + + # %% + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # Replot and add to Figure instance (-> works only for a Figure instance named fig) + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + fig_name_logo = create_logo() + + # Use position parameter of Figure.image + fig.image(imagefile=f"{fig_name_logo}.eps", position=position) + + Path.unlink(f"{fig_name_logo}.eps") -# %% -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Replot and add wordmark "PyGMT" -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -if wordmark is True: - match orientation: - case "vertical": - projection = f"X{size * 2 - 1.5}c/{size * 2}c" - position = f"jMC+w{size * 2 - 1.5}c+o0c/0.9c" - args_text = {"x": -3.2, "y": -2.8, "justify": "LM"} - args_cover = {"x": -2.2, "y": -2.8} - case "horizontal": - projection = f"X{size * 2}c/{size - 2}c" - position = f"jLM+w{size - 2}c" - args_text = {"x": -1.6, "y": 0, "justify": "LM"} - args_cover = {"x": -0.7, "y": 0} - - fig = pygmt.Figure() - frame_pen = "0.5p,gray20" if box else "cyan@100" - pygmt.config(MAP_FRAME_PEN=frame_pen) - fig.basemap(region=region, projection=projection, frame=[0, f"+g{color_bg}"]) - - fig.image(imagefile=f"{fig_name_rot}.eps", position=position) - - fig.text(text="PyGMT", font=f"45p,AvantGarde-Book,{color_gmt}", **args_text) - fig.plot(style="s2.6c", fill=color_bg, **args_cover) - fig.text(text="Py", font=f"45p,AvantGarde-Book,{color_py}", **args_text) - - # ............................................................................. - # Save - # ............................................................................. - fig_name_rot_text = f"{fig_name_rot}_wordmark_{orientation}" - for ext in ["png", "pdf", "eps"]: - # alpha_png = True if ext == "png" else False # problems with code style - alpha_png = False - if ext == "png": - alpha_png = True - fig.savefig( - fname=f"{fig_name_rot_text}.{ext}", dpi=dpi_png, transparent=alpha_png - ) - print(fig_name_rot_text) - Path.unlink(f"{fig_name_rot}.eps") # %% + +fig = pygmt.Figure() +fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gcyan"]) + +pygmtlogo() +pygmtlogo(orientation="vertical", position="jTL+o0.2c+w3c") +pygmtlogo(color_concept="bw", bg_concept="dark", position="jLB+o0.2c+w6c") +pygmtlogo(bg_concept="light", wordmark=False, bg_transparent=True, position="jMC+w4c") +pygmtlogo(color_concept="bw", bg_concept="light", shape="hexagon", wordmark=False, position="jRB+w4c", box=True) + fig.show() -Path.unlink(f"{fig_name}.eps") + From 93c9f057b8a60e6ba1d54022246d2850a06a6ca3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 17:56:12 +0100 Subject: [PATCH 029/379] Fix code style and add examples --- examples/gallery/embellishments/pygmt_logo.py | 84 ++++++++++++++----- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 684407b9ff3..4a54fd14cb6 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -36,6 +36,7 @@ import pygmt + # ----------------------------------------------------------------------------- # Changebale settings (-> adjust for your needs; later input for function) # ----------------------------------------------------------------------------- @@ -46,9 +47,12 @@ def pygmtlogo( wordmark=True, # True | False orientation="horizontal", # "horizontal" | "vertical" bg_transparent=False, # True | False - box=False, # True | False # TODO use box parameter of Figure.image + box=False, # True | False # -> use box parameter of Figure.image position="jRT+o0.1c+w4c", ): + """ + Docstrings + """ def create_logo( color_concept=color_concept, @@ -59,7 +63,6 @@ def create_logo( bg_transparent=bg_transparent, box=box, ): - # ----------------------------------------------------------------------------- # Define colors (-> can be discussed) # ----------------------------------------------------------------------------- @@ -137,13 +140,23 @@ def create_logo( fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow, no_clip=True) # diagonal yellow lines # upper left - fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow) + fig.plot( + x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow + ) # lower right - fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], pen=pen_yellow) + fig.plot( + x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], pen=pen_yellow + ) # lower left - fig.plot(x=[-xy_yellow_1, -xy_yellow_2], y=[-xy_yellow_1, -xy_yellow_2], pen=pen_yellow) + fig.plot( + x=[-xy_yellow_1, -xy_yellow_2], + y=[-xy_yellow_1, -xy_yellow_2], + pen=pen_yellow, + ) # upper right - fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], pen=pen_yellow) + fig.plot( + x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], pen=pen_yellow + ) # ............................................................................. # letter G @@ -198,7 +211,7 @@ def create_logo( # margin around shape with slight overplotting for clean borders color_margin = color_bg if color_concept == "color" and bg_transparent and not wordmark: - color_margin = "white" + color_margin = "white@100" fig.plot( x=0, y=0, @@ -213,7 +226,7 @@ def create_logo( # fig.show() fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" fig.savefig(fname=f"{fig_name}.eps") - print(fig_name) + # print(fig_name) # %% @@ -226,7 +239,9 @@ def create_logo( bg_alpha = 100 if bg_transparent is True else 0 fig.basemap( - region=region, projection=f"X{size * 2}c", frame=[0, f"+g{color_bg}@{bg_alpha}"] + region=region, + projection=f"X{(size + 0.3) * 2}c", + frame=[0, f"+g{color_bg}@{bg_alpha}"], ) fig.image( @@ -242,7 +257,7 @@ def create_logo( # fig.show() fig_name_rot = fig_name_logo = f"{fig_name}_rot{angle_rot}deg" fig.savefig(fname=f"{fig_name_rot}.eps") - print(fig_name_rot) + # print(fig_name_rot) # %% @@ -265,7 +280,9 @@ def create_logo( fig = pygmt.Figure() frame_pen = "0.5p,gray20" if box else "cyan@100" pygmt.config(MAP_FRAME_PEN=frame_pen) - fig.basemap(region=region, projection=projection, frame=[0, f"+g{color_bg}"]) + fig.basemap( + region=region, projection=projection, frame=[0, f"+g{color_bg}"] + ) fig.image(imagefile=f"{fig_name_rot}.eps", position=position) @@ -273,12 +290,12 @@ def create_logo( fig.plot(style="s2.6c", fill=color_bg, **args_cover) fig.text(text="Py", font=f"45p,AvantGarde-Book,{color_py}", **args_text) - # ............................................................................. + # ......................................................................... # Save - # ............................................................................. + # ......................................................................... fig_name_rot_text = fig_name_logo = f"{fig_name_rot}_wordmark_{orientation}" fig.savefig(fname=f"{fig_name_rot_text}.eps") - print(fig_name_rot_text) + # print(fig_name_rot_text) Path.unlink(f"{fig_name_rot}.eps") # %% @@ -287,8 +304,8 @@ def create_logo( return fig_name_logo - # %% + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Replot and add to Figure instance (-> works only for a Figure instance named fig) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -300,17 +317,44 @@ def create_logo( Path.unlink(f"{fig_name_logo}.eps") - # %% +# Plot logo in an existing Figure instance +# +# Limitations: +# - works only for a PyGMT Figure instance named "fig" +# - margin is now transparent but still included the size so can not use box parameter +# of Figure.image yet fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gcyan"]) pygmtlogo() -pygmtlogo(orientation="vertical", position="jTL+o0.2c+w3c") -pygmtlogo(color_concept="bw", bg_concept="dark", position="jLB+o0.2c+w6c") +pygmtlogo(bg_concept="light", position="jTR+o0.1c/2c+w4c", box=True) +pygmtlogo(orientation="vertical", position="jTL+o0.1c+w3c") +pygmtlogo(color_concept="bw", bg_concept="dark", position="jLB+o0.1c+w6c") pygmtlogo(bg_concept="light", wordmark=False, bg_transparent=True, position="jMC+w4c") -pygmtlogo(color_concept="bw", bg_concept="light", shape="hexagon", wordmark=False, position="jRB+w4c", box=True) +pygmtlogo( + color_concept="bw", + bg_concept="light", + shape="hexagon", + wordmark=False, + position="jRB+w4c", + box=True, +) +pygmtlogo( + color_concept="bw", + bg_concept="dark", + wordmark=False, + bg_transparent=True, + position="jLM+w2c", +) +pygmtlogo( + color_concept="bw", + bg_concept="dark", + shape="hexagon", + wordmark=False, + bg_transparent=True, + position="jRM+w2c", +) fig.show() - From 7cfea09b84724f671a41d7009c862e6941779905 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 18:05:55 +0100 Subject: [PATCH 030/379] Code formating --- examples/gallery/embellishments/pygmt_logo.py | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 4a54fd14cb6..3571ee4ae85 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -37,9 +37,6 @@ import pygmt -# ----------------------------------------------------------------------------- -# Changebale settings (-> adjust for your needs; later input for function) -# ----------------------------------------------------------------------------- def pygmtlogo( color_concept="color", # "color" | "bw" bg_concept="dark", # "light" | "dark" @@ -54,6 +51,8 @@ def pygmtlogo( Docstrings """ + # Start of subfunction + def create_logo( color_concept=color_concept, bg_concept=bg_concept, @@ -99,8 +98,6 @@ def create_logo( angle_rot = 30 # degrees - # %% - # ----------------------------------------------------------------------------- # Start plotting # ----------------------------------------------------------------------------- @@ -228,8 +225,6 @@ def create_logo( fig.savefig(fname=f"{fig_name}.eps") # print(fig_name) - # %% - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Replot and apply rotation # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -259,8 +254,6 @@ def create_logo( fig.savefig(fname=f"{fig_name_rot}.eps") # print(fig_name_rot) - # %% - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Replot and add wordmark "PyGMT" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -298,27 +291,26 @@ def create_logo( # print(fig_name_rot_text) Path.unlink(f"{fig_name_rot}.eps") - # %% # fig.show() Path.unlink(f"{fig_name}.eps") return fig_name_logo - # %% + # End of subfunction # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Replot and add to Figure instance (-> works only for a Figure instance named fig) + # Replot and add to existing Figure instance (-> requires Figure instance named fig) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig_name_logo = create_logo() - # Use position parameter of Figure.image + # Use parameters of Figure.image fig.image(imagefile=f"{fig_name_logo}.eps", position=position) Path.unlink(f"{fig_name_logo}.eps") # %% -# Plot logo in an existing Figure instance +# Plot logo in an existing PyGMT Figure instance # # Limitations: # - works only for a PyGMT Figure instance named "fig" From e9d17984fca2880cae1d2aa8f47459176c6562d8 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 18:06:11 +0100 Subject: [PATCH 031/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From dab45b9675f93c1350cfa08348d681444bccb74c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 18:15:17 +0100 Subject: [PATCH 032/379] Update examples --- examples/gallery/embellishments/pygmt_logo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 3571ee4ae85..8478eed9d1f --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -323,6 +323,9 @@ def create_logo( pygmtlogo() pygmtlogo(bg_concept="light", position="jTR+o0.1c/2c+w4c", box=True) pygmtlogo(orientation="vertical", position="jTL+o0.1c+w3c") +pygmtlogo( + bg_concept="light", orientation="vertical", position="jML+o0.1c/-1c+w3c", box=True +) pygmtlogo(color_concept="bw", bg_concept="dark", position="jLB+o0.1c+w6c") pygmtlogo(bg_concept="light", wordmark=False, bg_transparent=True, position="jMC+w4c") pygmtlogo( @@ -338,7 +341,7 @@ def create_logo( bg_concept="dark", wordmark=False, bg_transparent=True, - position="jLM+w2c", + position="jTC+w2c", ) pygmtlogo( color_concept="bw", From 67b13be73807d819fbe3f50b1087763b5550ffa7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 18:15:39 +0100 Subject: [PATCH 033/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 0fe36d372a902353a57452d93587bad99d228581 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 21:07:06 +0100 Subject: [PATCH 034/379] Remove withe margin |Use box parameter of Figure.image --- examples/gallery/embellishments/pygmt_logo.py | 110 +++++++++--------- 1 file changed, 52 insertions(+), 58 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 8478eed9d1f..aae84311bb4 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -44,13 +44,36 @@ def pygmtlogo( wordmark=True, # True | False orientation="horizontal", # "horizontal" | "vertical" bg_transparent=False, # True | False + position="jRT+o0.1c+w4c", # -> use position parameter of Figure.image box=False, # True | False # -> use box parameter of Figure.image - position="jRT+o0.1c+w4c", ): """ Docstrings """ + # ----------------------------------------------------------------------------- + # Define colors (-> can be discussed) + # ----------------------------------------------------------------------------- + if color_concept == "color": + color_blue = "48/105/152" # Python blue + color_yellow = "255/212/59" # Python yellow + color_red = "238/86/52" # GMT red + elif color_concept == "bw" and bg_concept == "light": + color_blue = color_yellow = color_red = "gray20" + elif color_concept == "bw" and bg_concept == "dark": + color_blue = color_yellow = color_red = "white" + + match bg_concept: + case "light": + color_bg = "white" + color_py = color_blue + color_gmt = "gray20" + case "dark": + color_bg = "gray20" + color_py = color_yellow + color_gmt = "white" + + # Start of subfunction def create_logo( @@ -60,29 +83,7 @@ def create_logo( wordmark=wordmark, orientation=orientation, bg_transparent=bg_transparent, - box=box, ): - # ----------------------------------------------------------------------------- - # Define colors (-> can be discussed) - # ----------------------------------------------------------------------------- - if color_concept == "color": - color_blue = "48/105/152" # Python blue - color_yellow = "255/212/59" # Python yellow - color_red = "238/86/52" # GMT red - elif color_concept == "bw" and bg_concept == "light": - color_blue = color_yellow = color_red = "gray20" - elif color_concept == "bw" and bg_concept == "dark": - color_blue = color_yellow = color_red = "white" - - match bg_concept: - case "light": - color_bg = "white" - color_py = color_blue - color_gmt = "gray20" - case "dark": - color_bg = "gray20" - color_py = color_yellow - color_gmt = "white" # ----------------------------------------------------------------------------- # Not-changebale settings (-> need to extended) @@ -117,10 +118,12 @@ def create_logo( diameter = 7.5 diameter_add = 0.5 symbol = "c" + margin = -1.2 case "hexagon": diameter = 8.6 diameter_add = 0.6 symbol = "h" + margin = -0.5 fig.plot( x=0, y=0, @@ -207,7 +210,8 @@ def create_logo( # margin around shape with slight overplotting for clean borders color_margin = color_bg - if color_concept == "color" and bg_transparent and not wordmark: + if (color_concept == "color" and bg_transparent and not wordmark) or \ + (color_concept == "bw" and bg_transparent and not wordmark and bg_concept == "light"): color_margin = "white@100" fig.plot( x=0, @@ -229,14 +233,13 @@ def create_logo( # Replot and apply rotation # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() - frame_pen = "0.5p,gray20" if box and not wordmark else "cyan@100" - pygmt.config(MAP_FRAME_PEN=frame_pen) + pygmt.config(MAP_FRAME_PEN="cyan@100") bg_alpha = 100 if bg_transparent is True else 0 fig.basemap( region=region, projection=f"X{(size + 0.3) * 2}c", - frame=[0, f"+g{color_bg}@{bg_alpha}"], + frame=f"+g{color_bg}@{bg_alpha}", ) fig.image( @@ -251,7 +254,7 @@ def create_logo( # ............................................................................. # fig.show() fig_name_rot = fig_name_logo = f"{fig_name}_rot{angle_rot}deg" - fig.savefig(fname=f"{fig_name_rot}.eps") + fig.savefig(fname=f"{fig_name_rot}.eps", resize=f"+m{margin}c") # print(fig_name_rot) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -261,20 +264,19 @@ def create_logo( match orientation: case "vertical": projection = f"X{size * 2 - 1.5}c/{size * 2}c" - position = f"jMC+w{size * 2 - 1.5}c+o0c/0.9c" + position = f"jTC+o0c/0.2c+w{size * 2 - 2.3}c" args_text = {"x": -3.2, "y": -2.8, "justify": "LM"} args_cover = {"x": -2.2, "y": -2.8} case "horizontal": projection = f"X{size * 2}c/{size - 2}c" - position = f"jLM+w{size - 2}c" - args_text = {"x": -1.6, "y": 0, "justify": "LM"} - args_cover = {"x": -0.7, "y": 0} + position = f"jLM+o0.2c/0c+w{size - 2.3}c" + args_text = {"x": -1.7, "y": 0, "justify": "LM"} + args_cover = {"x": -0.8, "y": 0} fig = pygmt.Figure() - frame_pen = "0.5p,gray20" if box else "cyan@100" - pygmt.config(MAP_FRAME_PEN=frame_pen) + pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap( - region=region, projection=projection, frame=[0, f"+g{color_bg}"] + region=region, projection=projection, frame=f"+g{color_bg}" ) fig.image(imagefile=f"{fig_name_rot}.eps", position=position) @@ -304,7 +306,7 @@ def create_logo( fig_name_logo = create_logo() # Use parameters of Figure.image - fig.image(imagefile=f"{fig_name_logo}.eps", position=position) + fig.image(imagefile=f"{fig_name_logo}.eps", position=position, box=box) Path.unlink(f"{fig_name_logo}.eps") @@ -312,44 +314,36 @@ def create_logo( # %% # Plot logo in an existing PyGMT Figure instance # -# Limitations: -# - works only for a PyGMT Figure instance named "fig" -# - margin is now transparent but still included the size so can not use box parameter -# of Figure.image yet +# Limitations: works only for a PyGMT Figure instance named "fig" fig = pygmt.Figure() -fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gcyan"]) +fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gtan"]) pygmtlogo() -pygmtlogo(bg_concept="light", position="jTR+o0.1c/2c+w4c", box=True) -pygmtlogo(orientation="vertical", position="jTL+o0.1c+w3c") -pygmtlogo( - bg_concept="light", orientation="vertical", position="jML+o0.1c/-1c+w3c", box=True -) -pygmtlogo(color_concept="bw", bg_concept="dark", position="jLB+o0.1c+w6c") -pygmtlogo(bg_concept="light", wordmark=False, bg_transparent=True, position="jMC+w4c") +pygmtlogo(bg_concept="light", shape="hexagon", position="jTL+o0.1c+w4c") + +pygmtlogo(shape="circle", wordmark=False, position="jML+w2c", box=True) +pygmtlogo(bg_concept="light", shape="circle", wordmark=False, bg_transparent=True, position="jBL+w2c", box=True) +pygmtlogo(color_concept="bw", shape="circle", wordmark=True, bg_transparent=True, orientation="vertical", position="jMC+w2c", box="+p1p,blue+gcyan") +pygmtlogo(color_concept="bw", shape="hexagon", wordmark=True, orientation="vertical", position="jBC+w2c", box="+ggray20") +pygmtlogo(shape="hexagon", wordmark=False, position="jMR+w2c", box=True) +pygmtlogo(bg_concept="light", shape="hexagon", wordmark=False, position="jBR+w2c", box=True) pygmtlogo( color_concept="bw", bg_concept="light", - shape="hexagon", - wordmark=False, - position="jRB+w4c", - box=True, -) -pygmtlogo( - color_concept="bw", - bg_concept="dark", + shape="circle", wordmark=False, + position="jTL+o0c/1.5c+w2c", bg_transparent=True, - position="jTC+w2c", ) pygmtlogo( color_concept="bw", bg_concept="dark", shape="hexagon", wordmark=False, + position="jTR+o0c/1.5c+w2c", bg_transparent=True, - position="jRM+w2c", ) fig.show() + From 5e19702c9a4715ee12a424c302d764fe61feaee3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 21:08:29 +0100 Subject: [PATCH 035/379] Follow coding style --- examples/gallery/embellishments/pygmt_logo.py | 47 ++++++++++++++----- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index aae84311bb4..97ffc774144 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -73,7 +73,6 @@ def pygmtlogo( color_py = color_yellow color_gmt = "white" - # Start of subfunction def create_logo( @@ -84,7 +83,6 @@ def create_logo( orientation=orientation, bg_transparent=bg_transparent, ): - # ----------------------------------------------------------------------------- # Not-changebale settings (-> need to extended) # ----------------------------------------------------------------------------- @@ -210,8 +208,12 @@ def create_logo( # margin around shape with slight overplotting for clean borders color_margin = color_bg - if (color_concept == "color" and bg_transparent and not wordmark) or \ - (color_concept == "bw" and bg_transparent and not wordmark and bg_concept == "light"): + if (color_concept == "color" and bg_transparent and not wordmark) or ( + color_concept == "bw" + and bg_transparent + and not wordmark + and bg_concept == "light" + ): color_margin = "white@100" fig.plot( x=0, @@ -275,9 +277,7 @@ def create_logo( fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") - fig.basemap( - region=region, projection=projection, frame=f"+g{color_bg}" - ) + fig.basemap(region=region, projection=projection, frame=f"+g{color_bg}") fig.image(imagefile=f"{fig_name_rot}.eps", position=position) @@ -323,11 +323,35 @@ def create_logo( pygmtlogo(bg_concept="light", shape="hexagon", position="jTL+o0.1c+w4c") pygmtlogo(shape="circle", wordmark=False, position="jML+w2c", box=True) -pygmtlogo(bg_concept="light", shape="circle", wordmark=False, bg_transparent=True, position="jBL+w2c", box=True) -pygmtlogo(color_concept="bw", shape="circle", wordmark=True, bg_transparent=True, orientation="vertical", position="jMC+w2c", box="+p1p,blue+gcyan") -pygmtlogo(color_concept="bw", shape="hexagon", wordmark=True, orientation="vertical", position="jBC+w2c", box="+ggray20") +pygmtlogo( + bg_concept="light", + shape="circle", + wordmark=False, + bg_transparent=True, + position="jBL+w2c", + box=True, +) +pygmtlogo( + color_concept="bw", + shape="circle", + wordmark=True, + bg_transparent=True, + orientation="vertical", + position="jMC+w2c", + box="+p1p,blue+gcyan", +) +pygmtlogo( + color_concept="bw", + shape="hexagon", + wordmark=True, + orientation="vertical", + position="jBC+w2c", + box="+ggray20", +) pygmtlogo(shape="hexagon", wordmark=False, position="jMR+w2c", box=True) -pygmtlogo(bg_concept="light", shape="hexagon", wordmark=False, position="jBR+w2c", box=True) +pygmtlogo( + bg_concept="light", shape="hexagon", wordmark=False, position="jBR+w2c", box=True +) pygmtlogo( color_concept="bw", bg_concept="light", @@ -346,4 +370,3 @@ def create_logo( ) fig.show() - From 1d075378b89455678d3dc346db9c4d2649b5876c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 21:09:50 +0100 Subject: [PATCH 036/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 432d6cf9e6569abe5e317e49b6adb397754904b0 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 21:24:00 +0100 Subject: [PATCH 037/379] Minor updates | add examples --- examples/gallery/embellishments/pygmt_logo.py | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 97ffc774144..37a36ac1ede --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -84,7 +84,7 @@ def create_logo( bg_transparent=bg_transparent, ): # ----------------------------------------------------------------------------- - # Not-changebale settings (-> need to extended) + # Not-changebale settings # ----------------------------------------------------------------------------- size = 4 region = [-size, size] * 2 @@ -106,7 +106,7 @@ def create_logo( # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") - fig.basemap(region=region, projection=f"X{size * 2}c", frame=[0, "+gcyan@100"]) + fig.basemap(region=region, projection=f"X{size * 2}c", frame="+gcyan@100") # ............................................................................. # blue circle / hexagon for Earth @@ -316,6 +316,27 @@ def create_logo( # # Limitations: works only for a PyGMT Figure instance named "fig" + +fig = pygmt.Figure() +pygmt.config(MAP_FRAME_PEN="cyan@100") +fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame="+gcyan@100") + +pygmtlogo(bg_concept="dark", position="jMC+w10c", wordmark=False, bg_transparent=True) + +fig.show() + +# %% + +fig = pygmt.Figure() +pygmt.config(MAP_FRAME_PEN="cyan@100") +fig.basemap(region=[-5, 5, -5, 5], projection="X10c/2c", frame="+gcyan@100") + +pygmtlogo(bg_concept="light", position="jMC+w10c") + +fig.show() + +# %% + fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gtan"]) From 725126d625134685a0ed690739fbb7c874e86902 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 21:24:37 +0100 Subject: [PATCH 038/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 361e3aa2b92ab0d772ad882d8d3d59fd8ea6081e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 21:25:27 +0100 Subject: [PATCH 039/379] Remove unneeded docs --- examples/gallery/embellishments/pygmt_logo.py | 4 ---- 1 file changed, 4 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 37a36ac1ede..cccc25a8dc9 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -25,10 +25,6 @@ ``True`` or ``False``. Only available for PNG format. Not supported for adding a wordmark. [Default is ``False``]. -- ``box``: add a box around the logo. - ``True`` or ``False``. - Mainly relevant for ``bg_concept = "light"``. - [Default is ``False``]. """ # %% From 9c9d19f7c1a0d688936d8c699ccb4283c7833066 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 21:52:54 +0100 Subject: [PATCH 040/379] Remove unneeded parameters from examples --- examples/gallery/embellishments/pygmt_logo.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index cccc25a8dc9..27385283173 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -342,7 +342,6 @@ def create_logo( pygmtlogo(shape="circle", wordmark=False, position="jML+w2c", box=True) pygmtlogo( bg_concept="light", - shape="circle", wordmark=False, bg_transparent=True, position="jBL+w2c", @@ -350,40 +349,34 @@ def create_logo( ) pygmtlogo( color_concept="bw", - shape="circle", - wordmark=True, - bg_transparent=True, orientation="vertical", + bg_transparent=True, position="jMC+w2c", box="+p1p,blue+gcyan", ) pygmtlogo( color_concept="bw", shape="hexagon", - wordmark=True, orientation="vertical", position="jBC+w2c", box="+ggray20", ) -pygmtlogo(shape="hexagon", wordmark=False, position="jMR+w2c", box=True) -pygmtlogo( - bg_concept="light", shape="hexagon", wordmark=False, position="jBR+w2c", box=True -) +pygmtlogo(shape="hexagon", wordmark=False, position="jMR+w2c") +pygmtlogo(bg_concept="light", shape="hexagon", wordmark=False, position="jBR+w2c") + pygmtlogo( color_concept="bw", bg_concept="light", - shape="circle", wordmark=False, - position="jTL+o0c/1.5c+w2c", bg_transparent=True, + position="jTL+o0c/1.5c+w2c", ) pygmtlogo( color_concept="bw", - bg_concept="dark", shape="hexagon", wordmark=False, - position="jTR+o0c/1.5c+w2c", bg_transparent=True, + position="jTR+o0c/1.5c+w2c", ) fig.show() From 9f1e8125d19b30827e130de6f400092506f5a7da Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 21:53:14 +0100 Subject: [PATCH 041/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 789d82e2e661591152184aebd91533b4b1026990 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 23:35:12 +0100 Subject: [PATCH 042/379] Improve names of parameters --- examples/gallery/embellishments/pygmt_logo.py | 101 ++++++++---------- 1 file changed, 46 insertions(+), 55 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 27385283173..e4597f586ec --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -5,26 +5,19 @@ by `@sfrooti `_. The logo consists of a visual and the wordmark "PyGMT". There are different versions available: -- ``color_concept``: colors of the visual and workmark. - Select between ``"colors"`` (colors for Python (blue and yellow) and GMT (red)) and - ``"bw"`` for black and white. - [Default is ``"color"``]. -- ``bg_concept``: color of the background. - Select between ``"light"`` (white) and ``"dark"`` (darkgray / gray20). - [Default is ``"dark"``]. -- ``shape``: shape of the visual. - Select between ``"circle"`` and ``"hexagon"``. - [Default is ``"circle"``]. +- ``black_white``: draw in black and white. + ``True`` colors for Python (blue and yellow) and GMT (red)) [Default] and ``False`` + for black and white. +- ``dark_mode``: use dark background. + ``True`` white and ``False`` arkgray / gray20 [Default]. +- ``hex_shape``: use hexagon shape. + ``True`` circle [Default] and ``False`` hexagon. - ``wordmark``: add the wordmark "PyGMT". - ``True`` or ``False``. - [Default is ``True``]. + ``True`` [Default] or ``False``. - ``orientation``: orientation of the wordmark. - Select between ``"vertical"`` (at the bottom) and ``"horizontal"`` (at the right). - [Default is ``"vertical"``]. + `"vertical"`` at the bottom and ``"horizontal"`` at the right [Default]. - ``bg_transparent``: make visual transparent outside of the circle or hexagon. - ``True`` or ``False``. - Only available for PNG format. Not supported for adding a wordmark. - [Default is ``False``]. + ``True`` or ``False``[Default]. Not supported for adding a wordmark. """ # %% @@ -34,12 +27,12 @@ def pygmtlogo( - color_concept="color", # "color" | "bw" - bg_concept="dark", # "light" | "dark" - shape="circle", # "circle" | "hexagon" - wordmark=True, # True | False + black_white=False, + dark_mode=True, + hex_shape=False, + wordmark=True, orientation="horizontal", # "horizontal" | "vertical" - bg_transparent=False, # True | False + bg_transparent=False, position="jRT+o0.1c+w4c", # -> use position parameter of Figure.image box=False, # True | False # -> use box parameter of Figure.image ): @@ -50,21 +43,21 @@ def pygmtlogo( # ----------------------------------------------------------------------------- # Define colors (-> can be discussed) # ----------------------------------------------------------------------------- - if color_concept == "color": + if not black_white: color_blue = "48/105/152" # Python blue color_yellow = "255/212/59" # Python yellow color_red = "238/86/52" # GMT red - elif color_concept == "bw" and bg_concept == "light": + elif black_white and not dark_mode: color_blue = color_yellow = color_red = "gray20" - elif color_concept == "bw" and bg_concept == "dark": + elif black_white and dark_mode: color_blue = color_yellow = color_red = "white" - match bg_concept: - case "light": + match dark_mode: + case False: color_bg = "white" color_py = color_blue color_gmt = "gray20" - case "dark": + case True: color_bg = "gray20" color_py = color_yellow color_gmt = "white" @@ -72,9 +65,9 @@ def pygmtlogo( # Start of subfunction def create_logo( - color_concept=color_concept, - bg_concept=bg_concept, - shape=shape, + black_white=black_white, + dark_mode=dark_mode, + hex_shape=hex_shape, wordmark=wordmark, orientation=orientation, bg_transparent=bg_transparent, @@ -107,13 +100,13 @@ def create_logo( # ............................................................................. # blue circle / hexagon for Earth # ............................................................................. - match shape: - case "circle": + match hex_shape: + case False: diameter = 7.5 diameter_add = 0.5 symbol = "c" margin = -1.2 - case "hexagon": + case True: diameter = 8.6 diameter_add = 0.6 symbol = "h" @@ -204,11 +197,8 @@ def create_logo( # margin around shape with slight overplotting for clean borders color_margin = color_bg - if (color_concept == "color" and bg_transparent and not wordmark) or ( - color_concept == "bw" - and bg_transparent - and not wordmark - and bg_concept == "light" + if (not black_white and bg_transparent and not wordmark) or ( + black_white and bg_transparent and not wordmark and not dark_mode ): color_margin = "white@100" fig.plot( @@ -223,7 +213,8 @@ def create_logo( # Save # ............................................................................. # fig.show() - fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" + # fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" + fig_name = "pygmt_logo" fig.savefig(fname=f"{fig_name}.eps") # print(fig_name) @@ -301,7 +292,7 @@ def create_logo( # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig_name_logo = create_logo() - # Use parameters of Figure.image + # Use parameters of pygmt.Figure.image fig.image(imagefile=f"{fig_name_logo}.eps", position=position, box=box) Path.unlink(f"{fig_name_logo}.eps") @@ -317,7 +308,7 @@ def create_logo( pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame="+gcyan@100") -pygmtlogo(bg_concept="dark", position="jMC+w10c", wordmark=False, bg_transparent=True) +pygmtlogo(position="jMC+w10c", wordmark=False, bg_transparent=True) fig.show() @@ -327,7 +318,7 @@ def create_logo( pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=[-5, 5, -5, 5], projection="X10c/2c", frame="+gcyan@100") -pygmtlogo(bg_concept="light", position="jMC+w10c") +pygmtlogo(dark_mode=False, position="jMC+w10c") fig.show() @@ -337,43 +328,43 @@ def create_logo( fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gtan"]) pygmtlogo() -pygmtlogo(bg_concept="light", shape="hexagon", position="jTL+o0.1c+w4c") +pygmtlogo(dark_mode=False, hex_shape=True, position="jTL+o0.1c+w4c") -pygmtlogo(shape="circle", wordmark=False, position="jML+w2c", box=True) +pygmtlogo(wordmark=False, position="jML+w2c", box=True) pygmtlogo( - bg_concept="light", + dark_mode=False, wordmark=False, bg_transparent=True, position="jBL+w2c", box=True, ) pygmtlogo( - color_concept="bw", + black_white=True, orientation="vertical", bg_transparent=True, position="jMC+w2c", box="+p1p,blue+gcyan", ) pygmtlogo( - color_concept="bw", - shape="hexagon", + black_white=True, + hex_shape=True, orientation="vertical", position="jBC+w2c", box="+ggray20", ) -pygmtlogo(shape="hexagon", wordmark=False, position="jMR+w2c") -pygmtlogo(bg_concept="light", shape="hexagon", wordmark=False, position="jBR+w2c") +pygmtlogo(hex_shape=True, wordmark=False, position="jMR+w2c") +pygmtlogo(dark_mode=False, hex_shape=True, wordmark=False, position="jBR+w2c") pygmtlogo( - color_concept="bw", - bg_concept="light", + black_white=True, + dark_mode=False, wordmark=False, bg_transparent=True, position="jTL+o0c/1.5c+w2c", ) pygmtlogo( - color_concept="bw", - shape="hexagon", + black_white=True, + hex_shape=True, wordmark=False, bg_transparent=True, position="jTR+o0c/1.5c+w2c", From b38edf954170809b104f99ec4c0c7a84417566cd Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 23:35:26 +0100 Subject: [PATCH 043/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From c8c7f795015a0e15355af242b06ee2266dad35e9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 23:39:26 +0100 Subject: [PATCH 044/379] Update parameter list explanaition --- examples/gallery/embellishments/pygmt_logo.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index e4597f586ec..93c4e5dc216 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -6,18 +6,18 @@ wordmark "PyGMT". There are different versions available: - ``black_white``: draw in black and white. - ``True`` colors for Python (blue and yellow) and GMT (red)) [Default] and ``False`` + ``False`` colors for Python (blue and yellow) and GMT (red)) [Default] or ``True`` for black and white. - ``dark_mode``: use dark background. - ``True`` white and ``False`` arkgray / gray20 [Default]. + ``False`` white or ``True`` darkgray / gray20 [Default]. - ``hex_shape``: use hexagon shape. - ``True`` circle [Default] and ``False`` hexagon. + ``False`` circle [Default] or ``True`` hexagon. - ``wordmark``: add the wordmark "PyGMT". - ``True`` [Default] or ``False``. + ``True`` with wordmark [Default] or ``False`` without wordmark. - ``orientation``: orientation of the wordmark. - `"vertical"`` at the bottom and ``"horizontal"`` at the right [Default]. + ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. - ``bg_transparent``: make visual transparent outside of the circle or hexagon. - ``True`` or ``False``[Default]. Not supported for adding a wordmark. + ``False``[Default] or ``True``. Not supported for adding a wordmark. """ # %% From ff0463535d8377d902c7cc7cbc25b6ebf4ee75d7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 23:39:49 +0100 Subject: [PATCH 045/379] Remove execusion permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 32c5341db70217485aa7ad2a2e2dbb76580a975c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 14 Mar 2025 23:41:32 +0100 Subject: [PATCH 046/379] Fix typo --- examples/gallery/embellishments/pygmt_logo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 93c4e5dc216..b1d611bd0e4 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -6,7 +6,7 @@ wordmark "PyGMT". There are different versions available: - ``black_white``: draw in black and white. - ``False`` colors for Python (blue and yellow) and GMT (red)) [Default] or ``True`` + ``False`` colors for Python (blue and yellow) and GMT (red) [Default] or ``True`` for black and white. - ``dark_mode``: use dark background. ``False`` white or ``True`` darkgray / gray20 [Default]. From b079fd9dfca659c4ff5ba0f28f8eae308ed63cc1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 09:31:26 +0100 Subject: [PATCH 047/379] Fix rst syntax --- examples/gallery/embellishments/pygmt_logo.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index b1d611bd0e4..608d87a9434 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -6,8 +6,7 @@ wordmark "PyGMT". There are different versions available: - ``black_white``: draw in black and white. - ``False`` colors for Python (blue and yellow) and GMT (red) [Default] or ``True`` - for black and white. + ``False`` colors for Python (blue and yellow) and GMT (red) [Default] or ``True`` for black and white. - ``dark_mode``: use dark background. ``False`` white or ``True`` darkgray / gray20 [Default]. - ``hex_shape``: use hexagon shape. @@ -17,7 +16,7 @@ - ``orientation``: orientation of the wordmark. ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. - ``bg_transparent``: make visual transparent outside of the circle or hexagon. - ``False``[Default] or ``True``. Not supported for adding a wordmark. + ``False`` [Default] or ``True``. Not supported for adding a wordmark. """ # %% From 90a289020f0e833a23edabc307fbba8fad96d8cb Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 09:33:27 +0100 Subject: [PATCH 048/379] Use variables for colors --- examples/gallery/embellishments/pygmt_logo.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 608d87a9434..17e1a1bb69b 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -42,24 +42,27 @@ def pygmtlogo( # ----------------------------------------------------------------------------- # Define colors (-> can be discussed) # ----------------------------------------------------------------------------- + color_dark = "gray20" + color_light = "white" + if not black_white: color_blue = "48/105/152" # Python blue color_yellow = "255/212/59" # Python yellow color_red = "238/86/52" # GMT red elif black_white and not dark_mode: - color_blue = color_yellow = color_red = "gray20" + color_blue = color_yellow = color_red = color_dark elif black_white and dark_mode: - color_blue = color_yellow = color_red = "white" + color_blue = color_yellow = color_red = color_light match dark_mode: case False: - color_bg = "white" + color_bg = color_light color_py = color_blue - color_gmt = "gray20" + color_gmt = color_dark case True: - color_bg = "gray20" + color_bg = color_dark color_py = color_yellow - color_gmt = "white" + color_gmt = color_light # Start of subfunction From 4c6013eaa4d9923c45a21197739ed592e79e0d32 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 09:37:39 +0100 Subject: [PATCH 049/379] Introduce transpareny for wordmark --- examples/gallery/embellishments/pygmt_logo.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 17e1a1bb69b..6fe1de65c12 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -15,8 +15,8 @@ ``True`` with wordmark [Default] or ``False`` without wordmark. - ``orientation``: orientation of the wordmark. ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. -- ``bg_transparent``: make visual transparent outside of the circle or hexagon. - ``False`` [Default] or ``True``. Not supported for adding a wordmark. +- ``bg_transparent``: make background transparent. + ``False`` not transparent [Default] or ``True`` transparent. """ # %% @@ -266,7 +266,9 @@ def create_logo( fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") - fig.basemap(region=region, projection=projection, frame=f"+g{color_bg}") + + bg_alpha = 100 if bg_transparent is True else 0 + fig.basemap(region=region, projection=projection, frame=f"+g{color_bg}@{bg_alpha}") fig.image(imagefile=f"{fig_name_rot}.eps", position=position) From f8ac7c0ec56578adac63339c086c56f6c12b933d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 09:39:34 +0100 Subject: [PATCH 050/379] Follow code style --- examples/gallery/embellishments/pygmt_logo.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 6fe1de65c12..d93af46c514 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -6,7 +6,8 @@ wordmark "PyGMT". There are different versions available: - ``black_white``: draw in black and white. - ``False`` colors for Python (blue and yellow) and GMT (red) [Default] or ``True`` for black and white. + ``False`` colors for Python (blue and yellow) and GMT (red) [Default] or ``True`` + for black and white. - ``dark_mode``: use dark background. ``False`` white or ``True`` darkgray / gray20 [Default]. - ``hex_shape``: use hexagon shape. @@ -42,8 +43,8 @@ def pygmtlogo( # ----------------------------------------------------------------------------- # Define colors (-> can be discussed) # ----------------------------------------------------------------------------- - color_dark = "gray20" - color_light = "white" + color_dark = "gray20" + color_light = "white" if not black_white: color_blue = "48/105/152" # Python blue @@ -268,7 +269,9 @@ def create_logo( pygmt.config(MAP_FRAME_PEN="cyan@100") bg_alpha = 100 if bg_transparent is True else 0 - fig.basemap(region=region, projection=projection, frame=f"+g{color_bg}@{bg_alpha}") + fig.basemap( + region=region, projection=projection, frame=f"+g{color_bg}@{bg_alpha}" + ) fig.image(imagefile=f"{fig_name_rot}.eps", position=position) From bdb6f14c4121786a2bdc5a747d4cc3a097a1bf54 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 09:56:18 +0100 Subject: [PATCH 051/379] Adjustments for tranparency for wordmark --- examples/gallery/embellishments/pygmt_logo.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index d93af46c514..c1bb95e889a 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -200,8 +200,8 @@ def create_logo( # margin around shape with slight overplotting for clean borders color_margin = color_bg - if (not black_white and bg_transparent and not wordmark) or ( - black_white and bg_transparent and not wordmark and not dark_mode + if (not black_white and bg_transparent) or ( + black_white and bg_transparent and not dark_mode ): color_margin = "white@100" fig.plot( @@ -258,12 +258,12 @@ def create_logo( projection = f"X{size * 2 - 1.5}c/{size * 2}c" position = f"jTC+o0c/0.2c+w{size * 2 - 2.3}c" args_text = {"x": -3.2, "y": -2.8, "justify": "LM"} - args_cover = {"x": -2.2, "y": -2.8} + # args_cover = {"x": -2.2, "y": -2.8} case "horizontal": projection = f"X{size * 2}c/{size - 2}c" position = f"jLM+o0.2c/0c+w{size - 2.3}c" args_text = {"x": -1.7, "y": 0, "justify": "LM"} - args_cover = {"x": -0.8, "y": 0} + # args_cover = {"x": -0.8, "y": 0} fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") @@ -276,7 +276,7 @@ def create_logo( fig.image(imagefile=f"{fig_name_rot}.eps", position=position) fig.text(text="PyGMT", font=f"45p,AvantGarde-Book,{color_gmt}", **args_text) - fig.plot(style="s2.6c", fill=color_bg, **args_cover) + # fig.plot(style="s2.6c", fill=color_bg, **args_cover) fig.text(text="Py", font=f"45p,AvantGarde-Book,{color_py}", **args_text) # ......................................................................... @@ -335,7 +335,10 @@ def create_logo( fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gtan"]) pygmtlogo() -pygmtlogo(dark_mode=False, hex_shape=True, position="jTL+o0.1c+w4c") +pygmtlogo( + dark_mode=False, hex_shape=True, position="jTL+o0.1c+w4c", bg_transparent=True +) +pygmtlogo(bg_transparent=True, position="jTC+o1c+w4c") pygmtlogo(wordmark=False, position="jML+w2c", box=True) pygmtlogo( From 74169790f925ac49295d6c47c1441b49e96c9b6c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 09:57:56 +0100 Subject: [PATCH 052/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From ebdf4f27bd68905837fba9b14a25dd458e8be2a7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 09:58:09 +0100 Subject: [PATCH 053/379] Adjust example --- examples/gallery/embellishments/pygmt_logo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index c1bb95e889a..6c3bc8d3196 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -338,7 +338,7 @@ def create_logo( pygmtlogo( dark_mode=False, hex_shape=True, position="jTL+o0.1c+w4c", bg_transparent=True ) -pygmtlogo(bg_transparent=True, position="jTC+o1c+w4c") +pygmtlogo(bg_transparent=True, position="jTC+o0c/1.5c+w4c") pygmtlogo(wordmark=False, position="jML+w2c", box=True) pygmtlogo( From 6d01ec12f7b45c78305d40e1a4429541ef9e32d7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 09:58:41 +0100 Subject: [PATCH 054/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From a60a88c82fe3a0e09d4d010a9c20afbe7b99db9a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 09:59:47 +0100 Subject: [PATCH 055/379] Add comment as reminder --- examples/gallery/embellishments/pygmt_logo.py | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 6c3bc8d3196..e1f3734279f --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -35,6 +35,7 @@ def pygmtlogo( bg_transparent=False, position="jRT+o0.1c+w4c", # -> use position parameter of Figure.image box=False, # True | False # -> use box parameter of Figure.image + # Combine bg_transparent and box ?! ): """ Docstrings From ec4583c7e85c2485cd0fb2cced36f3ff7648cad6 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 10:00:58 +0100 Subject: [PATCH 056/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 4891de295bce937e41fe79dcc3c12d21d899ef2f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 10:58:12 +0100 Subject: [PATCH 057/379] Combine box and bg_transparent to box parameter of Figure.image --- examples/gallery/embellishments/pygmt_logo.py | 85 ++++++++----------- 1 file changed, 37 insertions(+), 48 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index e1f3734279f..fd07333ede9 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -16,8 +16,6 @@ ``True`` with wordmark [Default] or ``False`` without wordmark. - ``orientation``: orientation of the wordmark. ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. -- ``bg_transparent``: make background transparent. - ``False`` not transparent [Default] or ``True`` transparent. """ # %% @@ -32,10 +30,8 @@ def pygmtlogo( hex_shape=False, wordmark=True, orientation="horizontal", # "horizontal" | "vertical" - bg_transparent=False, position="jRT+o0.1c+w4c", # -> use position parameter of Figure.image - box=False, # True | False # -> use box parameter of Figure.image - # Combine bg_transparent and box ?! + box=None, # -> use box parameter of Figure.image ): """ Docstrings @@ -51,10 +47,10 @@ def pygmtlogo( color_blue = "48/105/152" # Python blue color_yellow = "255/212/59" # Python yellow color_red = "238/86/52" # GMT red - elif black_white and not dark_mode: - color_blue = color_yellow = color_red = color_dark - elif black_white and dark_mode: + elif black_white: color_blue = color_yellow = color_red = color_light + if not dark_mode: + color_blue = color_yellow = color_red = color_dark match dark_mode: case False: @@ -66,6 +62,11 @@ def pygmtlogo( color_py = color_yellow color_gmt = color_light + if box == None: + box = f"+g{color_dark}" + if not dark_mode: + box = f"+g{color_light}" + # Start of subfunction def create_logo( @@ -74,7 +75,6 @@ def create_logo( hex_shape=hex_shape, wordmark=wordmark, orientation=orientation, - bg_transparent=bg_transparent, ): # ----------------------------------------------------------------------------- # Not-changebale settings @@ -199,25 +199,24 @@ def create_logo( # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}") - # margin around shape with slight overplotting for clean borders - color_margin = color_bg - if (not black_white and bg_transparent) or ( - black_white and bg_transparent and not dark_mode - ): - color_margin = "white@100" - fig.plot( - x=0, - y=0, - style=f"{symbol}{diameter + diameter_add}c", - pen=f"1p,{color_margin}", - no_clip=True, - ) + # # margin around shape with slight overplotting for clean borders + # color_margin = color_bg + # if (not black_white and bg_transparent) or ( + # black_white and bg_transparent and not dark_mode + # ): + # color_margin = "white@100" + # fig.plot( + # x=0, + # y=0, + # style=f"{symbol}{diameter + diameter_add}c", + # pen=f"1p,{color_margin}", + # no_clip=True, + # ) # ............................................................................. # Save # ............................................................................. # fig.show() - # fig_name = f"pygmt_logo_{shape}_{color_concept}_{bg_concept}" fig_name = "pygmt_logo" fig.savefig(fname=f"{fig_name}.eps") # print(fig_name) @@ -228,12 +227,7 @@ def create_logo( fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") - bg_alpha = 100 if bg_transparent is True else 0 - fig.basemap( - region=region, - projection=f"X{(size + 0.3) * 2}c", - frame=f"+g{color_bg}@{bg_alpha}", - ) + fig.basemap(region=region, projection=f"X{(size + 0.3) * 2}c", frame="+gcyan@100") fig.image( imagefile=f"{fig_name}.eps", @@ -259,26 +253,21 @@ def create_logo( projection = f"X{size * 2 - 1.5}c/{size * 2}c" position = f"jTC+o0c/0.2c+w{size * 2 - 2.3}c" args_text = {"x": -3.2, "y": -2.8, "justify": "LM"} - # args_cover = {"x": -2.2, "y": -2.8} case "horizontal": projection = f"X{size * 2}c/{size - 2}c" position = f"jLM+o0.2c/0c+w{size - 2.3}c" args_text = {"x": -1.7, "y": 0, "justify": "LM"} - # args_cover = {"x": -0.8, "y": 0} fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") - - bg_alpha = 100 if bg_transparent is True else 0 - fig.basemap( - region=region, projection=projection, frame=f"+g{color_bg}@{bg_alpha}" - ) + fig.basemap(region=region, projection=projection, frame="+gcyan@100") fig.image(imagefile=f"{fig_name_rot}.eps", position=position) fig.text(text="PyGMT", font=f"45p,AvantGarde-Book,{color_gmt}", **args_text) - # fig.plot(style="s2.6c", fill=color_bg, **args_cover) fig.text(text="Py", font=f"45p,AvantGarde-Book,{color_py}", **args_text) + # text_logo = f"@{color_py}Py@@;@{color_gmt}GMT@@;" + # fig.text(text=text_logo, font="45p,AvantGarde-Book", **args_text) # ......................................................................... # Save @@ -316,7 +305,7 @@ def create_logo( pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame="+gcyan@100") -pygmtlogo(position="jMC+w10c", wordmark=False, bg_transparent=True) +pygmtlogo(position="jMC+w10c", wordmark=False, box=False) fig.show() @@ -336,23 +325,21 @@ def create_logo( fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gtan"]) pygmtlogo() -pygmtlogo( - dark_mode=False, hex_shape=True, position="jTL+o0.1c+w4c", bg_transparent=True -) -pygmtlogo(bg_transparent=True, position="jTC+o0c/1.5c+w4c") +pygmtlogo(dark_mode=False, hex_shape=True, position="jTL+o0.1c+w4c", box=False) +pygmtlogo(position="jTC+o0c/1.5c+w4c", box="+p1p,black") + +""" pygmtlogo(wordmark=False, position="jML+w2c", box=True) pygmtlogo( dark_mode=False, wordmark=False, - bg_transparent=True, position="jBL+w2c", - box=True, + box="+p1p,black", ) pygmtlogo( black_white=True, orientation="vertical", - bg_transparent=True, position="jMC+w2c", box="+p1p,blue+gcyan", ) @@ -370,15 +357,17 @@ def create_logo( black_white=True, dark_mode=False, wordmark=False, - bg_transparent=True, position="jTL+o0c/1.5c+w2c", + box=False, ) pygmtlogo( black_white=True, hex_shape=True, wordmark=False, - bg_transparent=True, position="jTR+o0c/1.5c+w2c", + box=False, ) -fig.show() +""" + +fig.show() \ No newline at end of file From e3da0ce22a91cc904b67b275741670dcae9708fc Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 11:04:08 +0100 Subject: [PATCH 058/379] Simplify code --- examples/gallery/embellishments/pygmt_logo.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index fd07333ede9..8781cbcf387 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -62,16 +62,14 @@ def pygmtlogo( color_py = color_yellow color_gmt = color_light - if box == None: - box = f"+g{color_dark}" - if not dark_mode: - box = f"+g{color_light}" + if box is None: + box = f"+g{color_dark}" + if not dark_mode: + box = f"+g{color_light}" # Start of subfunction def create_logo( - black_white=black_white, - dark_mode=dark_mode, hex_shape=hex_shape, wordmark=wordmark, orientation=orientation, @@ -107,12 +105,12 @@ def create_logo( match hex_shape: case False: diameter = 7.5 - diameter_add = 0.5 + # diameter_add = 0.5 symbol = "c" margin = -1.2 case True: diameter = 8.6 - diameter_add = 0.6 + # diameter_add = 0.6 symbol = "h" margin = -0.5 fig.plot( @@ -227,7 +225,9 @@ def create_logo( fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") - fig.basemap(region=region, projection=f"X{(size + 0.3) * 2}c", frame="+gcyan@100") + fig.basemap( + region=region, projection=f"X{(size + 0.3) * 2}c", frame="+gcyan@100" + ) fig.image( imagefile=f"{fig_name}.eps", @@ -329,7 +329,7 @@ def create_logo( pygmtlogo(position="jTC+o0c/1.5c+w4c", box="+p1p,black") -""" +# """ pygmtlogo(wordmark=False, position="jML+w2c", box=True) pygmtlogo( dark_mode=False, @@ -368,6 +368,6 @@ def create_logo( box=False, ) -""" +# """ -fig.show() \ No newline at end of file +fig.show() From 78872b4272f7c17ee2053043a53826f315fb5ccb Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 11:13:31 +0100 Subject: [PATCH 059/379] Adjust outline --- examples/gallery/embellishments/pygmt_logo.py | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 8781cbcf387..e4487f5f99c 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -105,12 +105,12 @@ def create_logo( match hex_shape: case False: diameter = 7.5 - # diameter_add = 0.5 + diameter_add = 0.5 symbol = "c" margin = -1.2 case True: diameter = 8.6 - # diameter_add = 0.6 + diameter_add = 0.6 symbol = "h" margin = -0.5 fig.plot( @@ -197,19 +197,17 @@ def create_logo( # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}") - # # margin around shape with slight overplotting for clean borders - # color_margin = color_bg - # if (not black_white and bg_transparent) or ( - # black_white and bg_transparent and not dark_mode - # ): - # color_margin = "white@100" - # fig.plot( - # x=0, - # y=0, - # style=f"{symbol}{diameter + diameter_add}c", - # pen=f"1p,{color_margin}", - # no_clip=True, - # ) + # margin around shape for black_white in dark_mode + # Needed ??? + if black_white and dark_mode: + color_margin = color_dark + fig.plot( + x=0, + y=0, + style=f"{symbol}{diameter + diameter_add}c", + pen=f"1p,{color_margin}", + no_clip=True, + ) # ............................................................................. # Save @@ -266,8 +264,6 @@ def create_logo( fig.text(text="PyGMT", font=f"45p,AvantGarde-Book,{color_gmt}", **args_text) fig.text(text="Py", font=f"45p,AvantGarde-Book,{color_py}", **args_text) - # text_logo = f"@{color_py}Py@@;@{color_gmt}GMT@@;" - # fig.text(text=text_logo, font="45p,AvantGarde-Book", **args_text) # ......................................................................... # Save From 470ed44390713dedc113d66d430debc351214199 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 11:14:36 +0100 Subject: [PATCH 060/379] Try to use GMT color setting for font --- examples/gallery/embellishments/pygmt_logo.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index e4487f5f99c..40958f26111 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -262,8 +262,11 @@ def create_logo( fig.image(imagefile=f"{fig_name_rot}.eps", position=position) - fig.text(text="PyGMT", font=f"45p,AvantGarde-Book,{color_gmt}", **args_text) - fig.text(text="Py", font=f"45p,AvantGarde-Book,{color_py}", **args_text) + # fig.text(text="PyGMT", font=f"45p,AvantGarde-Book,{color_gmt}", **args_text) + # fig.text(text="Py", font=f"45p,AvantGarde-Book,{color_py}", **args_text) + # Try GMT color setting to avoid re / overplotting + text_wordmark = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" + fig.text(text=text_wordmark, font="45p,AvantGarde-Book", **args_text) # ......................................................................... # Save From e77dde205933304099018631b5326ba9f7c25f0f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 11:16:36 +0100 Subject: [PATCH 061/379] Remove unneeded code --- examples/gallery/embellishments/pygmt_logo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 40958f26111..1931d016a0f 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -262,8 +262,6 @@ def create_logo( fig.image(imagefile=f"{fig_name_rot}.eps", position=position) - # fig.text(text="PyGMT", font=f"45p,AvantGarde-Book,{color_gmt}", **args_text) - # fig.text(text="Py", font=f"45p,AvantGarde-Book,{color_py}", **args_text) # Try GMT color setting to avoid re / overplotting text_wordmark = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" fig.text(text=text_wordmark, font="45p,AvantGarde-Book", **args_text) From 126a574216c1ab0c450829399a4db79865884cee Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 11:17:02 +0100 Subject: [PATCH 062/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 5de896907806472396e6f991f731ec3d19a2a03c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 11:54:11 +0100 Subject: [PATCH 063/379] Polish code --- examples/gallery/embellishments/pygmt_logo.py | 117 +++++++++--------- 1 file changed, 61 insertions(+), 56 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 1931d016a0f..6b034d8d166 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -37,45 +37,59 @@ def pygmtlogo( Docstrings """ - # ----------------------------------------------------------------------------- - # Define colors (-> can be discussed) - # ----------------------------------------------------------------------------- - color_dark = "gray20" - color_light = "white" - - if not black_white: - color_blue = "48/105/152" # Python blue - color_yellow = "255/212/59" # Python yellow - color_red = "238/86/52" # GMT red - elif black_white: - color_blue = color_yellow = color_red = color_light - if not dark_mode: - color_blue = color_yellow = color_red = color_dark - - match dark_mode: - case False: - color_bg = color_light - color_py = color_blue - color_gmt = color_dark - case True: - color_bg = color_dark - color_py = color_yellow - color_gmt = color_light - - if box is None: - box = f"+g{color_dark}" - if not dark_mode: - box = f"+g{color_light}" - # Start of subfunction def create_logo( + black_white=black_white, + dark_mode=dark_mode, hex_shape=hex_shape, wordmark=wordmark, - orientation=orientation, + orientation=orientation ): # ----------------------------------------------------------------------------- - # Not-changebale settings + # Define colors + # ----------------------------------------------------------------------------- + color_dark = "gray20" + color_light = "white" + + # visual + if not black_white: + color_blue = "48/105/152" # Python blue + color_yellow = "255/212/59" # Python yellow + color_red = "238/86/52" # GMT red + elif black_white: + color_blue = color_yellow = color_red = color_light + if not dark_mode: + color_blue = color_yellow = color_red = color_dark + + # background and wordmark + match dark_mode: + case False: + color_bg = color_light + color_py = color_blue + color_gmt = color_dark + case True: + color_bg = color_dark + color_py = color_yellow + color_gmt = color_light + + # ----------------------------------------------------------------------------- + # Define shape + # ----------------------------------------------------------------------------- + match hex_shape: + case False: + diameter = 7.5 + diameter_add = 0.5 + symbol = "c" + margin = -1.2 + case True: + diameter = 8.6 + diameter_add = 0.6 + symbol = "h" + margin = -0.5 + + # ----------------------------------------------------------------------------- + # Helpful definitions # ----------------------------------------------------------------------------- size = 4 region = [-size, size] * 2 @@ -88,6 +102,9 @@ def create_logo( angle_rot = 30 # degrees + no_line = "cyan@100" + no_fill = f"+g{no_line}" + # ----------------------------------------------------------------------------- # Start plotting # ----------------------------------------------------------------------------- @@ -96,23 +113,12 @@ def create_logo( # Creating the visual # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN="cyan@100") - fig.basemap(region=region, projection=f"X{size * 2}c", frame="+gcyan@100") + pygmt.config(MAP_FRAME_PEN=no_line) + fig.basemap(region=region, projection=f"X{size * 2}c", frame=no_fill) # ............................................................................. # blue circle / hexagon for Earth # ............................................................................. - match hex_shape: - case False: - diameter = 7.5 - diameter_add = 0.5 - symbol = "c" - margin = -1.2 - case True: - diameter = 8.6 - diameter_add = 0.6 - symbol = "h" - margin = -0.5 fig.plot( x=0, y=0, @@ -200,12 +206,11 @@ def create_logo( # margin around shape for black_white in dark_mode # Needed ??? if black_white and dark_mode: - color_margin = color_dark fig.plot( x=0, y=0, style=f"{symbol}{diameter + diameter_add}c", - pen=f"1p,{color_margin}", + pen=f"1p,{color_dark}", no_clip=True, ) @@ -221,11 +226,8 @@ def create_logo( # Replot and apply rotation # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN="cyan@100") - - fig.basemap( - region=region, projection=f"X{(size + 0.3) * 2}c", frame="+gcyan@100" - ) + pygmt.config(MAP_FRAME_PEN=no_line) + fig.basemap(region=region, projection=f"X{(size + 0.3) * 2}c", frame=no_fill) fig.image( imagefile=f"{fig_name}.eps", @@ -257,8 +259,8 @@ def create_logo( args_text = {"x": -1.7, "y": 0, "justify": "LM"} fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN="cyan@100") - fig.basemap(region=region, projection=projection, frame="+gcyan@100") + pygmt.config(MAP_FRAME_PEN=no_line) + fig.basemap(region=region, projection=projection, frame=no_fill) fig.image(imagefile=f"{fig_name_rot}.eps", position=position) @@ -277,14 +279,17 @@ def create_logo( # fig.show() Path.unlink(f"{fig_name}.eps") - return fig_name_logo + return fig_name_logo, color_bg # End of subfunction # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Replot and add to existing Figure instance (-> requires Figure instance named fig) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - fig_name_logo = create_logo() + fig_name_logo, color_bg = create_logo() + + if box is None: + box = f"+g{color_bg}" # Use parameters of pygmt.Figure.image fig.image(imagefile=f"{fig_name_logo}.eps", position=position, box=box) From 77c12f8066063170bfc3996d693d955d79fc4714 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 11:55:54 +0100 Subject: [PATCH 064/379] Follow code style --- examples/gallery/embellishments/pygmt_logo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 6b034d8d166..c64e6bb2afb 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -44,7 +44,7 @@ def create_logo( dark_mode=dark_mode, hex_shape=hex_shape, wordmark=wordmark, - orientation=orientation + orientation=orientation, ): # ----------------------------------------------------------------------------- # Define colors From 76e1dac460444df75cd0d0cc2aee7ec96e33372a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 11:57:07 +0100 Subject: [PATCH 065/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 366970ae3b3d64e99b79a290fbdc64b258839bf1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 12:32:52 +0100 Subject: [PATCH 066/379] Use specific variable names --- examples/gallery/embellishments/pygmt_logo.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index c64e6bb2afb..d4b2ceabd14 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -250,30 +250,30 @@ def create_logo( if wordmark is True: match orientation: case "vertical": - projection = f"X{size * 2 - 1.5}c/{size * 2}c" - position = f"jTC+o0c/0.2c+w{size * 2 - 2.3}c" - args_text = {"x": -3.2, "y": -2.8, "justify": "LM"} + proj_wm = f"X{size * 2 - 1.5}c/{size * 2}c" + pos_wm = f"jTC+o0c/0.2c+w{size * 2 - 2.3}c" + args_text_wm = {"x": -3.2, "y": -2.8, "justify": "LM"} case "horizontal": - projection = f"X{size * 2}c/{size - 2}c" - position = f"jLM+o0.2c/0c+w{size - 2.3}c" - args_text = {"x": -1.7, "y": 0, "justify": "LM"} + proj_wm = f"X{size * 2}c/{size - 2}c" + pos_wm = f"jLM+o0.2c/0c+w{size - 2.3}c" + args_text_wm = {"x": -1.7, "y": 0, "justify": "LM"} fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN=no_line) - fig.basemap(region=region, projection=projection, frame=no_fill) + fig.basemap(region=region, projection=proj_wm, frame=no_fill) - fig.image(imagefile=f"{fig_name_rot}.eps", position=position) + fig.image(imagefile=f"{fig_name_rot}.eps", position=pos_wm) # Try GMT color setting to avoid re / overplotting - text_wordmark = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" - fig.text(text=text_wordmark, font="45p,AvantGarde-Book", **args_text) + text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" + fig.text(text=text_wm, font="45p,AvantGarde-Book", **args_text_wm) # ......................................................................... # Save # ......................................................................... - fig_name_rot_text = fig_name_logo = f"{fig_name_rot}_wordmark_{orientation}" - fig.savefig(fname=f"{fig_name_rot_text}.eps") - # print(fig_name_rot_text) + fig_name_rot_wm = fig_name_logo = f"{fig_name_rot}_wordmark_{orientation}" + fig.savefig(fname=f"{fig_name_rot_wm}.eps") + # print(fig_name_rot_wm) Path.unlink(f"{fig_name_rot}.eps") # fig.show() From 43d6d924f98a799cf052546fe0d782750705d053 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 12:33:43 +0100 Subject: [PATCH 067/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From e401feaa7ab24742369e951838e67c31bccf4bbb Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 13:42:10 +0100 Subject: [PATCH 068/379] Do rotation directly not eps export --- examples/gallery/embellishments/pygmt_logo.py | 108 +++++++++--------- 1 file changed, 53 insertions(+), 55 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index d4b2ceabd14..b570178107b --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -100,11 +100,14 @@ def create_logo( pen_yellow = f"5p,{color_yellow}" pen_red = f"10p,{color_red}" - angle_rot = 30 # degrees - - no_line = "cyan@100" + no_line = "cyan@10" no_fill = f"+g{no_line}" + # Rotation around z (vertical) axis placed in the center + # Has to be applied to each plotting command, up on second call set to True + angle_rot = 30 # degrees + perspective = f"{angle_rot}+w0/0" + # ----------------------------------------------------------------------------- # Start plotting # ----------------------------------------------------------------------------- @@ -114,7 +117,12 @@ def create_logo( # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN=no_line) - fig.basemap(region=region, projection=f"X{size * 2}c", frame=no_fill) + fig.basemap( + region=region, + projection=f"X{size * 2}c", + frame=no_fill, + perspective=perspective, + ) # ............................................................................. # blue circle / hexagon for Earth @@ -126,82 +134,93 @@ def create_logo( pen=f"15p,{color_blue}", fill=color_bg, no_clip=True, + perspective=True, ) # ............................................................................. # yellow lines for compass # ............................................................................. # horizontal yellow line - fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow, no_clip=True) + fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow, no_clip=True, perspective=True) # diagonal yellow lines + args_dia = {"pen": pen_yellow, "perspective": True} # upper left fig.plot( - x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], pen=pen_yellow + x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], **args_dia ) # lower right fig.plot( - x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], pen=pen_yellow + x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], **args_dia ) # lower left fig.plot( - x=[-xy_yellow_1, -xy_yellow_2], - y=[-xy_yellow_1, -xy_yellow_2], - pen=pen_yellow, + x=[-xy_yellow_1, -xy_yellow_2], y=[-xy_yellow_1, -xy_yellow_2], **args_dia ) # upper right - fig.plot( - x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], pen=pen_yellow - ) + fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], **args_dia) # ............................................................................. # letter G # ............................................................................. # horizontal red line - fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}") + fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}", perspective=True) # red ring sector - fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red) + fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red, perspective=True) # space between yellow lines and ring sector - fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg) + fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg, perspective=True) # vertical yellow line - fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}") + fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}", perspective=True) # cover yellow line in lower part of the ring sector - fig.plot(x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red) + fig.plot( + x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red, perspective=True + ) # ............................................................................. # upper vertical red line # ............................................................................. # space between red line and blue circle / hexagon - fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}") + fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}", perspective=True) # red line - fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}") + fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}", perspective=True) # ............................................................................. # letter M # ............................................................................. # space between letter M and yellow line at the right side # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") - fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}") + fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) # diagonal lines - fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], pen=pen_red) - fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], pen=pen_red) + fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], pen=pen_red, perspective=True) + fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], pen=pen_red, perspective=True) # middle pick - fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red) + fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) # vertical lines with small distance to horizontal line of letter G - fig.plot(x=[0.285, 0.285], y=[0.30, 1.65], pen=pen_red) - fig.plot(x=[1.47, 1.47], y=[0.30, 1.65], pen=pen_red) + fig.plot(x=[0.285, 0.285], y=[0.30, 1.65], pen=pen_red, perspective=True) + fig.plot(x=[1.47, 1.47], y=[0.30, 1.65], pen=pen_red, perspective=True) # ............................................................................. # letter T # ............................................................................. # red curved horizontal line - fig.plot(x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red) + fig.plot( + x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red, perspective=True + ) # vertical endings of curved horizontal line - fig.plot(x=[-1.05, -1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}") - fig.plot(x=[1.05, 1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}") + fig.plot( + x=[-1.05, -1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}", perspective=True + ) + fig.plot(x=[1.05, 1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}", perspective=True) # arrow head as inverse triangle with pen for space to blue circle / hexagon - fig.plot(x=0, y=-3.55, style="i1.1c", fill=color_red, pen=f"3p,{color_bg}") + fig.plot( + x=0, + y=-3.55, + style="i1.1c", + fill=color_red, + pen=f"3p,{color_bg}", + perspective=True, + ) # arrow tail - fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}") + fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) # margin around shape for black_white in dark_mode # Needed ??? @@ -212,35 +231,14 @@ def create_logo( style=f"{symbol}{diameter + diameter_add}c", pen=f"1p,{color_dark}", no_clip=True, + perspective=True, ) # ............................................................................. # Save # ............................................................................. # fig.show() - fig_name = "pygmt_logo" - fig.savefig(fname=f"{fig_name}.eps") - # print(fig_name) - - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Replot and apply rotation - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN=no_line) - fig.basemap(region=region, projection=f"X{(size + 0.3) * 2}c", frame=no_fill) - - fig.image( - imagefile=f"{fig_name}.eps", - position=f"jMC+w{size * 2}c", - # Rotation around z (vertical) axis placed in the center - perspective=f"{angle_rot}+w0/0", - ) - - # ............................................................................. - # Save - # ............................................................................. - # fig.show() - fig_name_rot = fig_name_logo = f"{fig_name}_rot{angle_rot}deg" + fig_name_rot = fig_name_logo = "pygmt_logo_rot" fig.savefig(fname=f"{fig_name_rot}.eps", resize=f"+m{margin}c") # print(fig_name_rot) @@ -277,7 +275,7 @@ def create_logo( Path.unlink(f"{fig_name_rot}.eps") # fig.show() - Path.unlink(f"{fig_name}.eps") + # Path.unlink(f"{fig_name}.eps") return fig_name_logo, color_bg From cbe6035848c0a21ab055b6511adee73ec9dd04c7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 13:42:29 +0100 Subject: [PATCH 069/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From e060bc71be74f79cfd372384bba0bd56b290dbd7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 13:43:57 +0100 Subject: [PATCH 070/379] Make full transparent --- examples/gallery/embellishments/pygmt_logo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index b570178107b..6440fa5791a --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -100,7 +100,7 @@ def create_logo( pen_yellow = f"5p,{color_yellow}" pen_red = f"10p,{color_red}" - no_line = "cyan@10" + no_line = "cyan@100" no_fill = f"+g{no_line}" # Rotation around z (vertical) axis placed in the center From d46d5e0c45780fb64ce631dc9332e17c19696a87 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 13:54:50 +0100 Subject: [PATCH 071/379] Use dicts --- examples/gallery/embellishments/pygmt_logo.py | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 6440fa5791a..9e91c051387 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -97,9 +97,6 @@ def create_logo( xy_yellow_1 = 2.65 xy_yellow_2 = 1.3 - pen_yellow = f"5p,{color_yellow}" - pen_red = f"10p,{color_red}" - no_line = "cyan@100" no_fill = f"+g{no_line}" @@ -140,24 +137,28 @@ def create_logo( # ............................................................................. # yellow lines for compass # ............................................................................. + args_yellow = {"pen": f"5p,{color_yellow}", "perspective": True} # horizontal yellow line - fig.plot(x=[-4, 4], y=[0, 0], pen=pen_yellow, no_clip=True, perspective=True) + fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) # diagonal yellow lines - args_dia = {"pen": pen_yellow, "perspective": True} # upper left fig.plot( - x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], **args_dia + x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], **args_yellow ) # lower right fig.plot( - x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], **args_dia + x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], **args_yellow ) # lower left fig.plot( - x=[-xy_yellow_1, -xy_yellow_2], y=[-xy_yellow_1, -xy_yellow_2], **args_dia + x=[-xy_yellow_1, -xy_yellow_2], + y=[-xy_yellow_1, -xy_yellow_2], + **args_yellow, ) # upper right - fig.plot(x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], **args_dia) + fig.plot( + x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], **args_yellow + ) # ............................................................................. # letter G @@ -189,14 +190,15 @@ def create_logo( # space between letter M and yellow line at the right side # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) + args_m = {"pen": f"10p,{color_red}", "perspective": True} # diagonal lines - fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], pen=pen_red, perspective=True) - fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], pen=pen_red, perspective=True) + fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], **args_m) + fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], **args_m) + # vertical lines with small distance to horizontal line of letter G + fig.plot(x=[0.285, 0.285], y=[0.30, 1.65], **args_m) + fig.plot(x=[1.47, 1.47], y=[0.30, 1.65], **args_m) # middle pick fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) - # vertical lines with small distance to horizontal line of letter G - fig.plot(x=[0.285, 0.285], y=[0.30, 1.65], pen=pen_red, perspective=True) - fig.plot(x=[1.47, 1.47], y=[0.30, 1.65], pen=pen_red, perspective=True) # ............................................................................. # letter T From cd38f53921365c0cc2203db539ab2310a79a6ec9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 13:55:24 +0100 Subject: [PATCH 072/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From e8dd40cf3bfaa25ee2793f92fa54e9a93bc81735 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 14:07:04 +0100 Subject: [PATCH 073/379] Suppress code style fails because of to many statements PLR0915 --- examples/gallery/embellishments/pygmt_logo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 9e91c051387..debef789c60 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -24,7 +24,7 @@ import pygmt -def pygmtlogo( +def pygmtlogo( # noqa: PLR0915 black_white=False, dark_mode=True, hex_shape=False, @@ -39,7 +39,7 @@ def pygmtlogo( # Start of subfunction - def create_logo( + def create_logo( # noqa: PLR0915 black_white=black_white, dark_mode=dark_mode, hex_shape=hex_shape, From 87dd5b7a9a36b1e3126077bcfdbd666d34dd52dc Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 14:08:36 +0100 Subject: [PATCH 074/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 5f492d7d76dbb62c8317b32145072b55da0bcd3d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 14:39:28 +0100 Subject: [PATCH 075/379] Add size of logo | add GMT in example | Polish code --- examples/gallery/embellishments/pygmt_logo.py | 93 ++++++++++--------- 1 file changed, 48 insertions(+), 45 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index debef789c60..d5fc54cf47a --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -30,7 +30,7 @@ def pygmtlogo( # noqa: PLR0915 hex_shape=False, wordmark=True, orientation="horizontal", # "horizontal" | "vertical" - position="jRT+o0.1c+w4c", # -> use position parameter of Figure.image + position="jRT+o0.1c+w5c", # -> use position parameter of Figure.image box=None, # -> use box parameter of Figure.image ): """ @@ -46,6 +46,24 @@ def create_logo( # noqa: PLR0915 wordmark=wordmark, orientation=orientation, ): + + # ----------------------------------------------------------------------------- + # Helpful definitions + # ----------------------------------------------------------------------------- + size = 4 + region = [-size, size] * 2 + + xy_yellow_1 = 2.65 + xy_yellow_2 = 1.3 + + no_line = "cyan@100" + no_fill = f"+g{no_line}" + + # Rotation around z (vertical) axis placed in the center + # Has to be applied to each plotting command, up on second call set to True + angle_rot = 30 # degrees + perspective = f"{angle_rot}+w0/0" + # ----------------------------------------------------------------------------- # Define colors # ----------------------------------------------------------------------------- @@ -89,21 +107,17 @@ def create_logo( # noqa: PLR0915 margin = -0.5 # ----------------------------------------------------------------------------- - # Helpful definitions + # Define wordmark # ----------------------------------------------------------------------------- - size = 4 - region = [-size, size] * 2 - - xy_yellow_1 = 2.65 - xy_yellow_2 = 1.3 - - no_line = "cyan@100" - no_fill = f"+g{no_line}" - - # Rotation around z (vertical) axis placed in the center - # Has to be applied to each plotting command, up on second call set to True - angle_rot = 30 # degrees - perspective = f"{angle_rot}+w0/0" + match orientation: + case "vertical": + proj_wm = f"X{size * 2 - 1.5}c/{size * 2}c" + pos_wm = f"jTC+o0c/0.2c+w{size * 2 - 2.3}c" + args_text_wm = {"x": -3.2, "y": -2.8, "justify": "LM"} + case "horizontal": + proj_wm = f"X{size * 2}c/{size - 2}c" + pos_wm = f"jLM+o0.1c/0c+w{size - 2}c" + args_text_wm = {"x": -1.5, "y": 0, "justify": "LM"} # ----------------------------------------------------------------------------- # Start plotting @@ -248,16 +262,6 @@ def create_logo( # noqa: PLR0915 # Replot and add wordmark "PyGMT" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if wordmark is True: - match orientation: - case "vertical": - proj_wm = f"X{size * 2 - 1.5}c/{size * 2}c" - pos_wm = f"jTC+o0c/0.2c+w{size * 2 - 2.3}c" - args_text_wm = {"x": -3.2, "y": -2.8, "justify": "LM"} - case "horizontal": - proj_wm = f"X{size * 2}c/{size - 2}c" - pos_wm = f"jLM+o0.2c/0c+w{size - 2.3}c" - args_text_wm = {"x": -1.7, "y": 0, "justify": "LM"} - fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN=no_line) fig.basemap(region=region, projection=proj_wm, frame=no_fill) @@ -302,7 +306,6 @@ def create_logo( # noqa: PLR0915 # # Limitations: works only for a PyGMT Figure instance named "fig" - fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame="+gcyan@100") @@ -326,12 +329,28 @@ def create_logo( # noqa: PLR0915 fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gtan"]) +fig.logo() # GMT logo + pygmtlogo() pygmtlogo(dark_mode=False, hex_shape=True, position="jTL+o0.1c+w4c", box=False) -pygmtlogo(position="jTC+o0c/1.5c+w4c", box="+p1p,black") +pygmtlogo(dark_mode=False, position="jTC+o0c/2c+w5c", box="+p1p,black") +pygmtlogo( + black_white=True, + dark_mode=False, + wordmark=False, + position="jTL+o0c/1.5c+w2c", + box=False, +) +pygmtlogo( + black_white=True, + hex_shape=True, + wordmark=False, + position="jTR+o0c/1.5c+w2c", + box=False, +) -# """ +""" pygmtlogo(wordmark=False, position="jML+w2c", box=True) pygmtlogo( dark_mode=False, @@ -354,22 +373,6 @@ def create_logo( # noqa: PLR0915 ) pygmtlogo(hex_shape=True, wordmark=False, position="jMR+w2c") pygmtlogo(dark_mode=False, hex_shape=True, wordmark=False, position="jBR+w2c") - -pygmtlogo( - black_white=True, - dark_mode=False, - wordmark=False, - position="jTL+o0c/1.5c+w2c", - box=False, -) -pygmtlogo( - black_white=True, - hex_shape=True, - wordmark=False, - position="jTR+o0c/1.5c+w2c", - box=False, -) - -# """ +""" fig.show() From b8150a5e6271f31a52121320f9400e638a22d42c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 14:40:06 +0100 Subject: [PATCH 076/379] Follow code style --- examples/gallery/embellishments/pygmt_logo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index d5fc54cf47a..1e5229beef5 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -46,7 +46,6 @@ def create_logo( # noqa: PLR0915 wordmark=wordmark, orientation=orientation, ): - # ----------------------------------------------------------------------------- # Helpful definitions # ----------------------------------------------------------------------------- From 8355de0804c8fa036c7634f30709c44903bab79b Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 14:53:19 +0100 Subject: [PATCH 077/379] Plot yellow lines via loop over list --- examples/gallery/embellishments/pygmt_logo.py | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 1e5229beef5..b96aa99fa75 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -154,24 +154,32 @@ def create_logo( # noqa: PLR0915 # horizontal yellow line fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) # diagonal yellow lines - # upper left - fig.plot( - x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], **args_yellow - ) - # lower right - fig.plot( - x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], **args_yellow - ) - # lower left - fig.plot( - x=[-xy_yellow_1, -xy_yellow_2], - y=[-xy_yellow_1, -xy_yellow_2], - **args_yellow, - ) - # upper right - fig.plot( - x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], **args_yellow - ) + # # upper left + # fig.plot( + # x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], **args_yellow + # ) + # # lower right + # fig.plot( + # x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], **args_yellow + # ) + # # lower left + # fig.plot( + # x=[-xy_yellow_1, -xy_yellow_2], + # y=[-xy_yellow_1, -xy_yellow_2], + # **args_yellow, + # ) + # # upper right + # fig.plot( + # x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], **args_yellow + # ) + diagonal_lines = [ + ([-xy_yellow_1, -xy_yellow_2], [xy_yellow_1, xy_yellow_2]), # upper left + ([xy_yellow_2, xy_yellow_1], [-xy_yellow_2, -xy_yellow_1]), # lower right + ([-xy_yellow_1, -xy_yellow_2], [-xy_yellow_1, -xy_yellow_2]), # lower left + ([xy_yellow_2, xy_yellow_1], [xy_yellow_2, xy_yellow_1]), # upper right + ] + for x_coords, y_coords in diagonal_lines: + fig.plot(x=x_coords, y=y_coords, **args_yellow) # ............................................................................. # letter G From 7d382b04dd565fa437b5e9659eba2656faf444fe Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 14:53:37 +0100 Subject: [PATCH 078/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From ff512cc5cb86b9f60fccf07592bea500928a3707 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 14:58:22 +0100 Subject: [PATCH 079/379] Plot red lines for letter M via loop over list --- examples/gallery/embellishments/pygmt_logo.py | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index b96aa99fa75..cc8b14040e8 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -154,24 +154,6 @@ def create_logo( # noqa: PLR0915 # horizontal yellow line fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) # diagonal yellow lines - # # upper left - # fig.plot( - # x=[-xy_yellow_1, -xy_yellow_2], y=[xy_yellow_1, xy_yellow_2], **args_yellow - # ) - # # lower right - # fig.plot( - # x=[xy_yellow_2, xy_yellow_1], y=[-xy_yellow_2, -xy_yellow_1], **args_yellow - # ) - # # lower left - # fig.plot( - # x=[-xy_yellow_1, -xy_yellow_2], - # y=[-xy_yellow_1, -xy_yellow_2], - # **args_yellow, - # ) - # # upper right - # fig.plot( - # x=[xy_yellow_2, xy_yellow_1], y=[xy_yellow_2, xy_yellow_1], **args_yellow - # ) diagonal_lines = [ ([-xy_yellow_1, -xy_yellow_2], [xy_yellow_1, xy_yellow_2]), # upper left ([xy_yellow_2, xy_yellow_1], [-xy_yellow_2, -xy_yellow_1]), # lower right @@ -211,13 +193,16 @@ def create_logo( # noqa: PLR0915 # space between letter M and yellow line at the right side # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) + # lines with small distance to horizontal line of letter G args_m = {"pen": f"10p,{color_red}", "perspective": True} - # diagonal lines - fig.plot(x=[0.33, 0.90], y=[1.527, 1.00], **args_m) - fig.plot(x=[0.90, 1.43], y=[1.00, 1.527], **args_m) - # vertical lines with small distance to horizontal line of letter G - fig.plot(x=[0.285, 0.285], y=[0.30, 1.65], **args_m) - fig.plot(x=[1.47, 1.47], y=[0.30, 1.65], **args_m) + lines_m = [ + ([0.33, 0.90], [1.527, 1.00]), # diagonal left + ([0.90, 1.43], [1.00, 1.527]), # diagonal right + ([0.285, 0.285], [0.30, 1.65]), # vertical left + ([1.47, 1.47], [0.30, 1.65]), # vertical right + ] + for x_coords, y_coords in lines_m: + fig.plot(x=x_coords, y=y_coords, **args_m) # middle pick fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) From c0727433207ba210910bf8741587813203e8fc5b Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 14:59:24 +0100 Subject: [PATCH 080/379] Adjust variable name --- examples/gallery/embellishments/pygmt_logo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index cc8b14040e8..15cb21dac77 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -154,13 +154,13 @@ def create_logo( # noqa: PLR0915 # horizontal yellow line fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) # diagonal yellow lines - diagonal_lines = [ + lines_diagonal = [ ([-xy_yellow_1, -xy_yellow_2], [xy_yellow_1, xy_yellow_2]), # upper left ([xy_yellow_2, xy_yellow_1], [-xy_yellow_2, -xy_yellow_1]), # lower right ([-xy_yellow_1, -xy_yellow_2], [-xy_yellow_1, -xy_yellow_2]), # lower left ([xy_yellow_2, xy_yellow_1], [xy_yellow_2, xy_yellow_1]), # upper right ] - for x_coords, y_coords in diagonal_lines: + for x_coords, y_coords in lines_diagonal: fig.plot(x=x_coords, y=y_coords, **args_yellow) # ............................................................................. From 5962954093d60e33141e906b155a509a5f84ac16 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 15:01:27 +0100 Subject: [PATCH 081/379] Use dict --- examples/gallery/embellishments/pygmt_logo.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 15cb21dac77..53613520373 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -214,10 +214,9 @@ def create_logo( # noqa: PLR0915 x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red, perspective=True ) # vertical endings of curved horizontal line - fig.plot( - x=[-1.05, -1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}", perspective=True - ) - fig.plot(x=[1.05, 1.05], y=[-1.5, -2.5], pen=f"9p,{color_bg}", perspective=True) + args_vert = {"y": [-1.5, -2.5], "pen": f"9p,{color_bg}", "perspective": True} + fig.plot(x=[-1.05, -1.05], **args_vert) + fig.plot(x=[1.05, 1.05], **args_vert) # arrow head as inverse triangle with pen for space to blue circle / hexagon fig.plot( x=0, From 5175a284924b62c682888cfe8fcbe629c100639c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 15:09:03 +0100 Subject: [PATCH 082/379] Reduce number of branches to be not > 12 --- examples/gallery/embellishments/pygmt_logo.py | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 53613520373..482b10f9193 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -70,40 +70,35 @@ def create_logo( # noqa: PLR0915 color_light = "white" # visual - if not black_white: - color_blue = "48/105/152" # Python blue - color_yellow = "255/212/59" # Python yellow - color_red = "238/86/52" # GMT red - elif black_white: + color_blue = "48/105/152" # Python blue + color_yellow = "255/212/59" # Python yellow + color_red = "238/86/52" # GMT red + if black_white: color_blue = color_yellow = color_red = color_light if not dark_mode: color_blue = color_yellow = color_red = color_dark # background and wordmark - match dark_mode: - case False: - color_bg = color_light - color_py = color_blue - color_gmt = color_dark - case True: - color_bg = color_dark - color_py = color_yellow - color_gmt = color_light + color_bg = color_dark + color_py = color_yellow + color_gmt = color_light + if not dark_mode: + color_bg = color_light + color_py = color_blue + color_gmt = color_dark # ----------------------------------------------------------------------------- # Define shape # ----------------------------------------------------------------------------- - match hex_shape: - case False: - diameter = 7.5 - diameter_add = 0.5 - symbol = "c" - margin = -1.2 - case True: - diameter = 8.6 - diameter_add = 0.6 - symbol = "h" - margin = -0.5 + symbol = "c" # circle + diameter = 7.5 + diameter_add = 0.5 + margin = -1.2 + if hex_shape: + symbol = "h" # hexagon + diameter = 8.6 + diameter_add = 0.6 + margin = -0.5 # ----------------------------------------------------------------------------- # Define wordmark From 3768a063e81dd179f93de8fe6d02b234ab43722b Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 15:10:27 +0100 Subject: [PATCH 083/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 433f8e4ee282d2f78e62dfbcc187f6d8d207919b Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 15:17:59 +0100 Subject: [PATCH 084/379] Improve comments --- examples/gallery/embellishments/pygmt_logo.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 482b10f9193..d5e591e4b6a --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -198,7 +198,7 @@ def create_logo( # noqa: PLR0915 ] for x_coords, y_coords in lines_m: fig.plot(x=x_coords, y=y_coords, **args_m) - # middle pick + # middle corner fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) # ............................................................................. @@ -224,8 +224,7 @@ def create_logo( # noqa: PLR0915 # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) - # margin around shape for black_white in dark_mode - # Needed ??? + # margin around shape for black_white in dark_mode - Needed ??? if black_white and dark_mode: fig.plot( x=0, From 479f4a276cea78846d27d86830dee4d4f2d70e59 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 15:18:26 +0100 Subject: [PATCH 085/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 4f9ae6f76514216ff1b123dc3d0ee975031f0eb9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 17:03:12 +0100 Subject: [PATCH 086/379] Do not rotate initial basemap -> no need of resize in savefig --- examples/gallery/embellishments/pygmt_logo.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index d5e591e4b6a..725e8ef27d4 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -60,6 +60,7 @@ def create_logo( # noqa: PLR0915 # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True + # Do NOT rotated initial basemap angle_rot = 30 # degrees perspective = f"{angle_rot}+w0/0" @@ -93,12 +94,10 @@ def create_logo( # noqa: PLR0915 symbol = "c" # circle diameter = 7.5 diameter_add = 0.5 - margin = -1.2 if hex_shape: symbol = "h" # hexagon diameter = 8.6 diameter_add = 0.6 - margin = -0.5 # ----------------------------------------------------------------------------- # Define wordmark @@ -106,7 +105,7 @@ def create_logo( # noqa: PLR0915 match orientation: case "vertical": proj_wm = f"X{size * 2 - 1.5}c/{size * 2}c" - pos_wm = f"jTC+o0c/0.2c+w{size * 2 - 2.3}c" + pos_wm = f"jTC+o0c/0.2c+w{size * 2 - 2.7}c" args_text_wm = {"x": -3.2, "y": -2.8, "justify": "LM"} case "horizontal": proj_wm = f"X{size * 2}c/{size - 2}c" @@ -126,7 +125,6 @@ def create_logo( # noqa: PLR0915 region=region, projection=f"X{size * 2}c", frame=no_fill, - perspective=perspective, ) # ............................................................................. @@ -139,7 +137,7 @@ def create_logo( # noqa: PLR0915 pen=f"15p,{color_blue}", fill=color_bg, no_clip=True, - perspective=True, + perspective=perspective, ) # ............................................................................. @@ -240,7 +238,7 @@ def create_logo( # noqa: PLR0915 # ............................................................................. # fig.show() fig_name_rot = fig_name_logo = "pygmt_logo_rot" - fig.savefig(fname=f"{fig_name_rot}.eps", resize=f"+m{margin}c") + fig.savefig(fname=f"{fig_name_rot}.eps") # print(fig_name_rot) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -324,16 +322,21 @@ def create_logo( # noqa: PLR0915 black_white=True, dark_mode=False, wordmark=False, - position="jTL+o0c/1.5c+w2c", + position="jTL+o0.5c/2c+w1.5c", box=False, ) pygmtlogo( black_white=True, hex_shape=True, wordmark=False, - position="jTR+o0c/1.5c+w2c", + position="jTR+o0.5c/2c+w1.5c", box=False, ) +pygmtlogo( + black_white=True, + orientation="vertical", + position="jMC+w2c", +) """ pygmtlogo(wordmark=False, position="jML+w2c", box=True) From 08c7e565152ee4380f1176194c3dcdd37e01b51e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 17:04:53 +0100 Subject: [PATCH 087/379] Follow code style --- examples/gallery/embellishments/pygmt_logo.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 725e8ef27d4..ed1663619b1 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -332,11 +332,7 @@ def create_logo( # noqa: PLR0915 position="jTR+o0.5c/2c+w1.5c", box=False, ) -pygmtlogo( - black_white=True, - orientation="vertical", - position="jMC+w2c", -) +pygmtlogo(black_white=True, orientation="vertical", position="jMC+w2c") """ pygmtlogo(wordmark=False, position="jML+w2c", box=True) From 8cb9079ccefc397b65620ada6f614a0328b357f0 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 17:05:09 +0100 Subject: [PATCH 088/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From d2f479d531f095e77bfbcfdb5fcc4a6274a3cd68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 15 Mar 2025 19:54:50 +0100 Subject: [PATCH 089/379] No temp eps file for wordmark Co-authored-by: Dongdong Tian --- examples/gallery/embellishments/pygmt_logo.py | 30 +++---------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index ed1663619b1..d2dd7ff6216 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -233,36 +233,14 @@ def create_logo( # noqa: PLR0915 perspective=True, ) - # ............................................................................. - # Save - # ............................................................................. - # fig.show() - fig_name_rot = fig_name_logo = "pygmt_logo_rot" - fig.savefig(fname=f"{fig_name_rot}.eps") - # print(fig_name_rot) - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Replot and add wordmark "PyGMT" + # Add wordmark "PyGMT" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if wordmark is True: - fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN=no_line) - fig.basemap(region=region, projection=proj_wm, frame=no_fill) - - fig.image(imagefile=f"{fig_name_rot}.eps", position=pos_wm) - - # Try GMT color setting to avoid re / overplotting text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" - fig.text(text=text_wm, font="45p,AvantGarde-Book", **args_text_wm) - - # ......................................................................... - # Save - # ......................................................................... - fig_name_rot_wm = fig_name_logo = f"{fig_name_rot}_wordmark_{orientation}" - fig.savefig(fname=f"{fig_name_rot_wm}.eps") - # print(fig_name_rot_wm) - Path.unlink(f"{fig_name_rot}.eps") - + fig.text(text=text_wm, no_clip=True, **args_text_wm) + fig_name_logo = "pygmt_logo" + fig.savefig(fname=f"{fig_name_logo}.eps") # fig.show() # Path.unlink(f"{fig_name}.eps") From f304d49d3653237a09563ce84767cac5cdffa9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 15 Mar 2025 19:55:37 +0100 Subject: [PATCH 090/379] Adjust position and font size for wordmark based on orientation Co-authored-by: Dongdong Tian --- examples/gallery/embellishments/pygmt_logo.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index d2dd7ff6216..30d1610a816 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -104,13 +104,10 @@ def create_logo( # noqa: PLR0915 # ----------------------------------------------------------------------------- match orientation: case "vertical": - proj_wm = f"X{size * 2 - 1.5}c/{size * 2}c" - pos_wm = f"jTC+o0c/0.2c+w{size * 2 - 2.7}c" - args_text_wm = {"x": -3.2, "y": -2.8, "justify": "LM"} + args_text_wm = {"x": 0, "y": -4.5, "justify": "CT", "font": "2.5c,AvantGarde-Book"} case "horizontal": - proj_wm = f"X{size * 2}c/{size - 2}c" - pos_wm = f"jLM+o0.1c/0c+w{size - 2}c" - args_text_wm = {"x": -1.5, "y": 0, "justify": "LM"} + args_text_wm = {"x": 4.5, "y": 0, "justify": "LM", "font": "8c,AvantGarde-Book"} + # ----------------------------------------------------------------------------- # Start plotting From f7a84c590ed19e6774b7e6b1662d263b70d73b54 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 19:57:23 +0100 Subject: [PATCH 091/379] Follow code style --- examples/gallery/embellishments/pygmt_logo.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 30d1610a816..53bced64a17 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -104,10 +104,19 @@ def create_logo( # noqa: PLR0915 # ----------------------------------------------------------------------------- match orientation: case "vertical": - args_text_wm = {"x": 0, "y": -4.5, "justify": "CT", "font": "2.5c,AvantGarde-Book"} + args_text_wm = { + "x": 0, + "y": -4.5, + "justify": "CT", + "font": "2.5c,AvantGarde-Book", + } case "horizontal": - args_text_wm = {"x": 4.5, "y": 0, "justify": "LM", "font": "8c,AvantGarde-Book"} - + args_text_wm = { + "x": 4.5, + "y": 0, + "justify": "LM", + "font": "8c,AvantGarde-Book", + } # ----------------------------------------------------------------------------- # Start plotting From b18f81696903536d8e453f418450ae71f0131600 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 20:03:32 +0100 Subject: [PATCH 092/379] Comment code --- examples/gallery/embellishments/pygmt_logo.py | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 53bced64a17..305a0d0d610 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -37,7 +37,9 @@ def pygmtlogo( # noqa: PLR0915 Docstrings """ + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Start of subfunction + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def create_logo( # noqa: PLR0915 black_white=black_white, @@ -121,10 +123,6 @@ def create_logo( # noqa: PLR0915 # ----------------------------------------------------------------------------- # Start plotting # ----------------------------------------------------------------------------- - - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Creating the visual - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN=no_line) fig.basemap( @@ -239,24 +237,28 @@ def create_logo( # noqa: PLR0915 perspective=True, ) - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # ............................................................................. # Add wordmark "PyGMT" - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if wordmark is True: + # ............................................................................. + if wordmark: text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" fig.text(text=text_wm, no_clip=True, **args_text_wm) + + # ............................................................................. + # Save + # ............................................................................. fig_name_logo = "pygmt_logo" fig.savefig(fname=f"{fig_name_logo}.eps") - # fig.show() - # Path.unlink(f"{fig_name}.eps") return fig_name_logo, color_bg + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # End of subfunction - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + # ----------------------------------------------------------------------------- # Replot and add to existing Figure instance (-> requires Figure instance named fig) - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # ----------------------------------------------------------------------------- fig_name_logo, color_bg = create_logo() if box is None: From 5ff52a829d5ac12e1ef58b48f743eb366be6cfd8 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 20:04:54 +0100 Subject: [PATCH 093/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 9297ac5d2a88ec731ae91b643caf4eb7517f9ad8 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 21:13:53 +0100 Subject: [PATCH 094/379] Adjust position of wordmark --- examples/gallery/embellishments/pygmt_logo.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index 305a0d0d610..db2ba1ec95f --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -104,20 +104,21 @@ def create_logo( # noqa: PLR0915 # ----------------------------------------------------------------------------- # Define wordmark # ----------------------------------------------------------------------------- + font = "AvantGarde-Book" match orientation: case "vertical": args_text_wm = { "x": 0, - "y": -4.5, + "y": -5, "justify": "CT", - "font": "2.5c,AvantGarde-Book", + "font": f"2.5c,{font}", } case "horizontal": args_text_wm = { - "x": 4.5, + "x": 6, "y": 0, "justify": "LM", - "font": "8c,AvantGarde-Book", + "font": f"8c,{font}", } # ----------------------------------------------------------------------------- From 50e361bfc6cad556b56d36454212746ba06dada7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 21:14:11 +0100 Subject: [PATCH 095/379] Remove execution permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From 09471e8f01d4cb6079c4e2c13b608312e96c5174 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:00:15 +0100 Subject: [PATCH 096/379] Create pygmtlogo.py in src and move code --- pygmt/src/pygmtlogo.py | 255 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100755 pygmt/src/pygmtlogo.py diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py new file mode 100755 index 00000000000..1f6e6782113 --- /dev/null +++ b/pygmt/src/pygmtlogo.py @@ -0,0 +1,255 @@ +""" +pygmtlogo - Create and plot the PyGMT logo. +""" + +from pathlib import Path + +import pygmt + + +def pygmtlogo( # noqa: PLR0915 + self, + black_white=False, + dark_mode=True, + hex_shape=False, + wordmark=True, + orientation="horizontal", # "horizontal" | "vertical" + position="jRT+o0.1c+w5c", # -> use position parameter of Figure.image + box=None, # -> use box parameter of Figure.image +): + """ + Docstrings + """ + + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # Start of subfunction + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + def create_logo( # noqa: PLR0915 + black_white=black_white, + dark_mode=dark_mode, + hex_shape=hex_shape, + wordmark=wordmark, + orientation=orientation, + ): + # ----------------------------------------------------------------------------- + # Helpful definitions + # ----------------------------------------------------------------------------- + size = 4 + region = [-size, size] * 2 + + xy_yellow_1 = 2.65 + xy_yellow_2 = 1.3 + + no_line = "cyan@100" + no_fill = f"+g{no_line}" + + # Rotation around z (vertical) axis placed in the center + # Has to be applied to each plotting command, up on second call set to True + # Do NOT rotated initial basemap + angle_rot = 30 # degrees + perspective = f"{angle_rot}+w0/0" + + # ----------------------------------------------------------------------------- + # Define colors + # ----------------------------------------------------------------------------- + color_dark = "gray20" + color_light = "white" + + # visual + color_blue = "48/105/152" # Python blue + color_yellow = "255/212/59" # Python yellow + color_red = "238/86/52" # GMT red + if black_white: + color_blue = color_yellow = color_red = color_light + if not dark_mode: + color_blue = color_yellow = color_red = color_dark + + # background and wordmark + color_bg = color_dark + color_py = color_yellow + color_gmt = color_light + if not dark_mode: + color_bg = color_light + color_py = color_blue + color_gmt = color_dark + + # ----------------------------------------------------------------------------- + # Define shape + # ----------------------------------------------------------------------------- + symbol = "c" # circle + diameter = 7.5 + diameter_add = 0.5 + if hex_shape: + symbol = "h" # hexagon + diameter = 8.6 + diameter_add = 0.6 + + # ----------------------------------------------------------------------------- + # Define wordmark + # ----------------------------------------------------------------------------- + font = "AvantGarde-Book" + match orientation: + case "vertical": + args_text_wm = { + "x": 0, + "y": -5, + "justify": "CT", + "font": f"2.5c,{font}", + } + case "horizontal": + args_text_wm = { + "x": 6, + "y": 0, + "justify": "LM", + "font": f"8c,{font}", + } + + # ----------------------------------------------------------------------------- + # Start plotting + # ----------------------------------------------------------------------------- + fig = pygmt.Figure() + pygmt.config(MAP_FRAME_PEN=no_line) + fig.basemap( + region=region, + projection=f"X{size * 2}c", + frame=no_fill, + ) + + # ............................................................................. + # blue circle / hexagon for Earth + # ............................................................................. + fig.plot( + x=0, + y=0, + style=f"{symbol}{diameter}c", + pen=f"15p,{color_blue}", + fill=color_bg, + no_clip=True, + perspective=perspective, + ) + + # ............................................................................. + # yellow lines for compass + # ............................................................................. + args_yellow = {"pen": f"5p,{color_yellow}", "perspective": True} + # horizontal yellow line + fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) + # diagonal yellow lines + lines_diagonal = [ + ([-xy_yellow_1, -xy_yellow_2], [xy_yellow_1, xy_yellow_2]), # upper left + ([xy_yellow_2, xy_yellow_1], [-xy_yellow_2, -xy_yellow_1]), # lower right + ([-xy_yellow_1, -xy_yellow_2], [-xy_yellow_1, -xy_yellow_2]), # lower left + ([xy_yellow_2, xy_yellow_1], [xy_yellow_2, xy_yellow_1]), # upper right + ] + for x_coords, y_coords in lines_diagonal: + fig.plot(x=x_coords, y=y_coords, **args_yellow) + + # ............................................................................. + # letter G + # ............................................................................. + # horizontal red line + fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}", perspective=True) + # red ring sector + fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red, perspective=True) + # space between yellow lines and ring sector + fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg, perspective=True) + # vertical yellow line + fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}", perspective=True) + # cover yellow line in lower part of the ring sector + fig.plot( + x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red, perspective=True + ) + + # ............................................................................. + # upper vertical red line + # ............................................................................. + # space between red line and blue circle / hexagon + fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}", perspective=True) + # red line + fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}", perspective=True) + + # ............................................................................. + # letter M + # ............................................................................. + # space between letter M and yellow line at the right side + # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") + fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) + # lines with small distance to horizontal line of letter G + args_m = {"pen": f"10p,{color_red}", "perspective": True} + lines_m = [ + ([0.33, 0.90], [1.527, 1.00]), # diagonal left + ([0.90, 1.43], [1.00, 1.527]), # diagonal right + ([0.285, 0.285], [0.30, 1.65]), # vertical left + ([1.47, 1.47], [0.30, 1.65]), # vertical right + ] + for x_coords, y_coords in lines_m: + fig.plot(x=x_coords, y=y_coords, **args_m) + # middle corner + fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) + + # ............................................................................. + # letter T + # ............................................................................. + # red curved horizontal line + fig.plot( + x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red, perspective=True + ) + # vertical endings of curved horizontal line + args_vert = {"y": [-1.5, -2.5], "pen": f"9p,{color_bg}", "perspective": True} + fig.plot(x=[-1.05, -1.05], **args_vert) + fig.plot(x=[1.05, 1.05], **args_vert) + # arrow head as inverse triangle with pen for space to blue circle / hexagon + fig.plot( + x=0, + y=-3.55, + style="i1.1c", + fill=color_red, + pen=f"3p,{color_bg}", + perspective=True, + ) + # arrow tail + fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) + + # margin around shape for black_white in dark_mode - Needed ??? + if black_white and dark_mode: + fig.plot( + x=0, + y=0, + style=f"{symbol}{diameter + diameter_add}c", + pen=f"1p,{color_dark}", + no_clip=True, + perspective=True, + ) + + # ............................................................................. + # Add wordmark "PyGMT" + # ............................................................................. + if wordmark: + text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" + fig.text(text=text_wm, no_clip=True, **args_text_wm) + + # ............................................................................. + # Save + # ............................................................................. + fig_name_logo = "pygmt_logo" + fig.savefig(fname=f"{fig_name_logo}.eps") + + return fig_name_logo, color_bg + + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # End of subfunction + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + # ----------------------------------------------------------------------------- + # Replot and add to existing Figure instance + # ----------------------------------------------------------------------------- + fig_name_logo, color_bg = create_logo() + + if box is None: + box = f"+g{color_bg}" + + # Use parameters of pygmt.Figure.image + self.image(imagefile=f"{fig_name_logo}.eps", position=position, box=box) + + Path.unlink(f"{fig_name_logo}.eps") From 0a35459a4d15c029f1ee3ccb6bc53aca1f07841a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:01:01 +0100 Subject: [PATCH 097/379] Update __init__.py --- pygmt/src/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/src/__init__.py b/pygmt/src/__init__.py index 8905124f917..93be835fffb 100644 --- a/pygmt/src/__init__.py +++ b/pygmt/src/__init__.py @@ -42,6 +42,7 @@ from pygmt.src.plot3d import plot3d from pygmt.src.project import project from pygmt.src.psconvert import psconvert +from pygmt.src.pygmtlogo import pygmtlogo from pygmt.src.rose import rose from pygmt.src.select import select from pygmt.src.shift_origin import shift_origin From b4259adeba7686ced9b6b8ce11ae2ae5377863c3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:01:21 +0100 Subject: [PATCH 098/379] Update figure.py --- pygmt/figure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/figure.py b/pygmt/figure.py index 5c5d4734ce6..26aad0557c6 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -427,6 +427,7 @@ def _repr_html_(self) -> str: plot, plot3d, psconvert, + pygmtlogo, rose, set_panel, shift_origin, From 06fbfbd5eb884ac6c575c7e0f0dd337a2fd6bbe8 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:01:51 +0100 Subject: [PATCH 099/379] Update gallery exampel --- examples/gallery/embellishments/pygmt_logo.py | 282 +----------------- 1 file changed, 12 insertions(+), 270 deletions(-) mode change 100644 => 100755 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100644 new mode 100755 index db2ba1ec95f..477a5b463e3 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -18,264 +18,6 @@ ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. """ -# %% -from pathlib import Path - -import pygmt - - -def pygmtlogo( # noqa: PLR0915 - black_white=False, - dark_mode=True, - hex_shape=False, - wordmark=True, - orientation="horizontal", # "horizontal" | "vertical" - position="jRT+o0.1c+w5c", # -> use position parameter of Figure.image - box=None, # -> use box parameter of Figure.image -): - """ - Docstrings - """ - - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Start of subfunction - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - def create_logo( # noqa: PLR0915 - black_white=black_white, - dark_mode=dark_mode, - hex_shape=hex_shape, - wordmark=wordmark, - orientation=orientation, - ): - # ----------------------------------------------------------------------------- - # Helpful definitions - # ----------------------------------------------------------------------------- - size = 4 - region = [-size, size] * 2 - - xy_yellow_1 = 2.65 - xy_yellow_2 = 1.3 - - no_line = "cyan@100" - no_fill = f"+g{no_line}" - - # Rotation around z (vertical) axis placed in the center - # Has to be applied to each plotting command, up on second call set to True - # Do NOT rotated initial basemap - angle_rot = 30 # degrees - perspective = f"{angle_rot}+w0/0" - - # ----------------------------------------------------------------------------- - # Define colors - # ----------------------------------------------------------------------------- - color_dark = "gray20" - color_light = "white" - - # visual - color_blue = "48/105/152" # Python blue - color_yellow = "255/212/59" # Python yellow - color_red = "238/86/52" # GMT red - if black_white: - color_blue = color_yellow = color_red = color_light - if not dark_mode: - color_blue = color_yellow = color_red = color_dark - - # background and wordmark - color_bg = color_dark - color_py = color_yellow - color_gmt = color_light - if not dark_mode: - color_bg = color_light - color_py = color_blue - color_gmt = color_dark - - # ----------------------------------------------------------------------------- - # Define shape - # ----------------------------------------------------------------------------- - symbol = "c" # circle - diameter = 7.5 - diameter_add = 0.5 - if hex_shape: - symbol = "h" # hexagon - diameter = 8.6 - diameter_add = 0.6 - - # ----------------------------------------------------------------------------- - # Define wordmark - # ----------------------------------------------------------------------------- - font = "AvantGarde-Book" - match orientation: - case "vertical": - args_text_wm = { - "x": 0, - "y": -5, - "justify": "CT", - "font": f"2.5c,{font}", - } - case "horizontal": - args_text_wm = { - "x": 6, - "y": 0, - "justify": "LM", - "font": f"8c,{font}", - } - - # ----------------------------------------------------------------------------- - # Start plotting - # ----------------------------------------------------------------------------- - fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN=no_line) - fig.basemap( - region=region, - projection=f"X{size * 2}c", - frame=no_fill, - ) - - # ............................................................................. - # blue circle / hexagon for Earth - # ............................................................................. - fig.plot( - x=0, - y=0, - style=f"{symbol}{diameter}c", - pen=f"15p,{color_blue}", - fill=color_bg, - no_clip=True, - perspective=perspective, - ) - - # ............................................................................. - # yellow lines for compass - # ............................................................................. - args_yellow = {"pen": f"5p,{color_yellow}", "perspective": True} - # horizontal yellow line - fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) - # diagonal yellow lines - lines_diagonal = [ - ([-xy_yellow_1, -xy_yellow_2], [xy_yellow_1, xy_yellow_2]), # upper left - ([xy_yellow_2, xy_yellow_1], [-xy_yellow_2, -xy_yellow_1]), # lower right - ([-xy_yellow_1, -xy_yellow_2], [-xy_yellow_1, -xy_yellow_2]), # lower left - ([xy_yellow_2, xy_yellow_1], [xy_yellow_2, xy_yellow_1]), # upper right - ] - for x_coords, y_coords in lines_diagonal: - fig.plot(x=x_coords, y=y_coords, **args_yellow) - - # ............................................................................. - # letter G - # ............................................................................. - # horizontal red line - fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}", perspective=True) - # red ring sector - fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red, perspective=True) - # space between yellow lines and ring sector - fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg, perspective=True) - # vertical yellow line - fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}", perspective=True) - # cover yellow line in lower part of the ring sector - fig.plot( - x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red, perspective=True - ) - - # ............................................................................. - # upper vertical red line - # ............................................................................. - # space between red line and blue circle / hexagon - fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}", perspective=True) - # red line - fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}", perspective=True) - - # ............................................................................. - # letter M - # ............................................................................. - # space between letter M and yellow line at the right side - # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") - fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) - # lines with small distance to horizontal line of letter G - args_m = {"pen": f"10p,{color_red}", "perspective": True} - lines_m = [ - ([0.33, 0.90], [1.527, 1.00]), # diagonal left - ([0.90, 1.43], [1.00, 1.527]), # diagonal right - ([0.285, 0.285], [0.30, 1.65]), # vertical left - ([1.47, 1.47], [0.30, 1.65]), # vertical right - ] - for x_coords, y_coords in lines_m: - fig.plot(x=x_coords, y=y_coords, **args_m) - # middle corner - fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) - - # ............................................................................. - # letter T - # ............................................................................. - # red curved horizontal line - fig.plot( - x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red, perspective=True - ) - # vertical endings of curved horizontal line - args_vert = {"y": [-1.5, -2.5], "pen": f"9p,{color_bg}", "perspective": True} - fig.plot(x=[-1.05, -1.05], **args_vert) - fig.plot(x=[1.05, 1.05], **args_vert) - # arrow head as inverse triangle with pen for space to blue circle / hexagon - fig.plot( - x=0, - y=-3.55, - style="i1.1c", - fill=color_red, - pen=f"3p,{color_bg}", - perspective=True, - ) - # arrow tail - fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) - - # margin around shape for black_white in dark_mode - Needed ??? - if black_white and dark_mode: - fig.plot( - x=0, - y=0, - style=f"{symbol}{diameter + diameter_add}c", - pen=f"1p,{color_dark}", - no_clip=True, - perspective=True, - ) - - # ............................................................................. - # Add wordmark "PyGMT" - # ............................................................................. - if wordmark: - text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" - fig.text(text=text_wm, no_clip=True, **args_text_wm) - - # ............................................................................. - # Save - # ............................................................................. - fig_name_logo = "pygmt_logo" - fig.savefig(fname=f"{fig_name_logo}.eps") - - return fig_name_logo, color_bg - - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # End of subfunction - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - # ----------------------------------------------------------------------------- - # Replot and add to existing Figure instance (-> requires Figure instance named fig) - # ----------------------------------------------------------------------------- - fig_name_logo, color_bg = create_logo() - - if box is None: - box = f"+g{color_bg}" - - # Use parameters of pygmt.Figure.image - fig.image(imagefile=f"{fig_name_logo}.eps", position=position, box=box) - - Path.unlink(f"{fig_name_logo}.eps") - - -# %% -# Plot logo in an existing PyGMT Figure instance -# -# Limitations: works only for a PyGMT Figure instance named "fig" - fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame="+gcyan@100") @@ -301,49 +43,49 @@ def create_logo( # noqa: PLR0915 fig.logo() # GMT logo -pygmtlogo() -pygmtlogo(dark_mode=False, hex_shape=True, position="jTL+o0.1c+w4c", box=False) -pygmtlogo(dark_mode=False, position="jTC+o0c/2c+w5c", box="+p1p,black") +fig.pygmtlogo() +fig.pygmtlogo(dark_mode=False, hex_shape=True, position="jTL+o0.1c+w4c", box=False) +fig.pygmtlogo(dark_mode=False, position="jTC+o0c/2c+w5c", box="+p1p,black") -pygmtlogo( +fig.pygmtlogo( black_white=True, dark_mode=False, wordmark=False, position="jTL+o0.5c/2c+w1.5c", box=False, ) -pygmtlogo( +fig.pygmtlogo( black_white=True, hex_shape=True, wordmark=False, position="jTR+o0.5c/2c+w1.5c", box=False, ) -pygmtlogo(black_white=True, orientation="vertical", position="jMC+w2c") +fig.pygmtlogo(black_white=True, orientation="vertical", position="jMC+w2c") """ -pygmtlogo(wordmark=False, position="jML+w2c", box=True) -pygmtlogo( +fig.pygmtlogo(wordmark=False, position="jML+w2c", box=True) +fig.pygmtlogo( dark_mode=False, wordmark=False, position="jBL+w2c", box="+p1p,black", ) -pygmtlogo( +fig.pygmtlogo( black_white=True, orientation="vertical", position="jMC+w2c", box="+p1p,blue+gcyan", ) -pygmtlogo( +fig.pygmtlogo( black_white=True, hex_shape=True, orientation="vertical", position="jBC+w2c", box="+ggray20", ) -pygmtlogo(hex_shape=True, wordmark=False, position="jMR+w2c") -pygmtlogo(dark_mode=False, hex_shape=True, wordmark=False, position="jBR+w2c") +fig.pygmtlogo(hex_shape=True, wordmark=False, position="jMR+w2c") +fig.pygmtlogo(dark_mode=False, hex_shape=True, wordmark=False, position="jBR+w2c") """ fig.show() From c9c9d75e34b36acd117b8a76bad6c0d1f571328f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:09:25 +0100 Subject: [PATCH 100/379] Add Docstrings --- pygmt/src/pygmtlogo.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 1f6e6782113..edb933f7a1c 100755 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -18,9 +18,23 @@ def pygmtlogo( # noqa: PLR0915 box=None, # -> use box parameter of Figure.image ): """ - Docstrings - """ + Plot the PyGMT logo. + + Parameters + ---------- + black_white : Draw in black and white. + ``False`` use colors for Python (blue and yellow) and GMT (red) [Default] or + ``True`` for black and white. + dark_mode : Use dark background. + ``False`` white or ``True`` darkgray [Default]. + hex_shape : Use hexagon shape. + ``False`` circle [Default] or ``True`` hexagon. + wordmark : add the wordmark "PyGMT". + ``True`` with wordmark [Default] or ``False`` without wordmark. + orientation : Orientation of the wordmark. + ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. + """ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Start of subfunction # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From efff20422b3459a42ed5a939e7956d1e5e27c888 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:16:01 +0100 Subject: [PATCH 101/379] Fix import in Gallery example --- examples/gallery/embellishments/pygmt_logo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 477a5b463e3..28084560226 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -18,6 +18,8 @@ ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. """ +import pygmt + fig = pygmt.Figure() pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame="+gcyan@100") From 7779832b4fe36e731f6452822c403bb969e17021 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:25:27 +0100 Subject: [PATCH 102/379] Update index --- doc/api/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/api/index.rst b/doc/api/index.rst index 25de6d44adf..e1895262909 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -33,6 +33,7 @@ Plotting map elements Figure.inset Figure.legend Figure.logo + Figure.pygmtlogo Figure.solar Figure.text Figure.timestamp From 79500dd3e0a2e9b1e38e49c54b64cddfcd48a54e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:26:46 +0100 Subject: [PATCH 103/379] Update gallery example --- examples/gallery/embellishments/pygmt_logo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 28084560226..34b8eee194e 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -24,7 +24,7 @@ pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame="+gcyan@100") -pygmtlogo(position="jMC+w10c", wordmark=False, box=False) +fig.pygmtlogo(position="jMC+w10c", wordmark=False, box=False) fig.show() @@ -34,7 +34,7 @@ pygmt.config(MAP_FRAME_PEN="cyan@100") fig.basemap(region=[-5, 5, -5, 5], projection="X10c/2c", frame="+gcyan@100") -pygmtlogo(dark_mode=False, position="jMC+w10c") +fig.pygmtlogo(dark_mode=False, position="jMC+w10c") fig.show() From 7f9d57ed88b6ea8eed21f883ba9a5fefcb0d8343 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:27:14 +0100 Subject: [PATCH 104/379] Update imports --- pygmt/src/pygmtlogo.py | 538 ++++++++++++++++++++--------------------- 1 file changed, 269 insertions(+), 269 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index edb933f7a1c..5a1a1bd32eb 100755 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -1,269 +1,269 @@ -""" -pygmtlogo - Create and plot the PyGMT logo. -""" - -from pathlib import Path - -import pygmt - - -def pygmtlogo( # noqa: PLR0915 - self, - black_white=False, - dark_mode=True, - hex_shape=False, - wordmark=True, - orientation="horizontal", # "horizontal" | "vertical" - position="jRT+o0.1c+w5c", # -> use position parameter of Figure.image - box=None, # -> use box parameter of Figure.image -): - """ - Plot the PyGMT logo. - - Parameters - ---------- - - black_white : Draw in black and white. - ``False`` use colors for Python (blue and yellow) and GMT (red) [Default] or - ``True`` for black and white. - dark_mode : Use dark background. - ``False`` white or ``True`` darkgray [Default]. - hex_shape : Use hexagon shape. - ``False`` circle [Default] or ``True`` hexagon. - wordmark : add the wordmark "PyGMT". - ``True`` with wordmark [Default] or ``False`` without wordmark. - orientation : Orientation of the wordmark. - ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. - """ - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Start of subfunction - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - def create_logo( # noqa: PLR0915 - black_white=black_white, - dark_mode=dark_mode, - hex_shape=hex_shape, - wordmark=wordmark, - orientation=orientation, - ): - # ----------------------------------------------------------------------------- - # Helpful definitions - # ----------------------------------------------------------------------------- - size = 4 - region = [-size, size] * 2 - - xy_yellow_1 = 2.65 - xy_yellow_2 = 1.3 - - no_line = "cyan@100" - no_fill = f"+g{no_line}" - - # Rotation around z (vertical) axis placed in the center - # Has to be applied to each plotting command, up on second call set to True - # Do NOT rotated initial basemap - angle_rot = 30 # degrees - perspective = f"{angle_rot}+w0/0" - - # ----------------------------------------------------------------------------- - # Define colors - # ----------------------------------------------------------------------------- - color_dark = "gray20" - color_light = "white" - - # visual - color_blue = "48/105/152" # Python blue - color_yellow = "255/212/59" # Python yellow - color_red = "238/86/52" # GMT red - if black_white: - color_blue = color_yellow = color_red = color_light - if not dark_mode: - color_blue = color_yellow = color_red = color_dark - - # background and wordmark - color_bg = color_dark - color_py = color_yellow - color_gmt = color_light - if not dark_mode: - color_bg = color_light - color_py = color_blue - color_gmt = color_dark - - # ----------------------------------------------------------------------------- - # Define shape - # ----------------------------------------------------------------------------- - symbol = "c" # circle - diameter = 7.5 - diameter_add = 0.5 - if hex_shape: - symbol = "h" # hexagon - diameter = 8.6 - diameter_add = 0.6 - - # ----------------------------------------------------------------------------- - # Define wordmark - # ----------------------------------------------------------------------------- - font = "AvantGarde-Book" - match orientation: - case "vertical": - args_text_wm = { - "x": 0, - "y": -5, - "justify": "CT", - "font": f"2.5c,{font}", - } - case "horizontal": - args_text_wm = { - "x": 6, - "y": 0, - "justify": "LM", - "font": f"8c,{font}", - } - - # ----------------------------------------------------------------------------- - # Start plotting - # ----------------------------------------------------------------------------- - fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN=no_line) - fig.basemap( - region=region, - projection=f"X{size * 2}c", - frame=no_fill, - ) - - # ............................................................................. - # blue circle / hexagon for Earth - # ............................................................................. - fig.plot( - x=0, - y=0, - style=f"{symbol}{diameter}c", - pen=f"15p,{color_blue}", - fill=color_bg, - no_clip=True, - perspective=perspective, - ) - - # ............................................................................. - # yellow lines for compass - # ............................................................................. - args_yellow = {"pen": f"5p,{color_yellow}", "perspective": True} - # horizontal yellow line - fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) - # diagonal yellow lines - lines_diagonal = [ - ([-xy_yellow_1, -xy_yellow_2], [xy_yellow_1, xy_yellow_2]), # upper left - ([xy_yellow_2, xy_yellow_1], [-xy_yellow_2, -xy_yellow_1]), # lower right - ([-xy_yellow_1, -xy_yellow_2], [-xy_yellow_1, -xy_yellow_2]), # lower left - ([xy_yellow_2, xy_yellow_1], [xy_yellow_2, xy_yellow_1]), # upper right - ] - for x_coords, y_coords in lines_diagonal: - fig.plot(x=x_coords, y=y_coords, **args_yellow) - - # ............................................................................. - # letter G - # ............................................................................. - # horizontal red line - fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}", perspective=True) - # red ring sector - fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red, perspective=True) - # space between yellow lines and ring sector - fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg, perspective=True) - # vertical yellow line - fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}", perspective=True) - # cover yellow line in lower part of the ring sector - fig.plot( - x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red, perspective=True - ) - - # ............................................................................. - # upper vertical red line - # ............................................................................. - # space between red line and blue circle / hexagon - fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}", perspective=True) - # red line - fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}", perspective=True) - - # ............................................................................. - # letter M - # ............................................................................. - # space between letter M and yellow line at the right side - # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") - fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) - # lines with small distance to horizontal line of letter G - args_m = {"pen": f"10p,{color_red}", "perspective": True} - lines_m = [ - ([0.33, 0.90], [1.527, 1.00]), # diagonal left - ([0.90, 1.43], [1.00, 1.527]), # diagonal right - ([0.285, 0.285], [0.30, 1.65]), # vertical left - ([1.47, 1.47], [0.30, 1.65]), # vertical right - ] - for x_coords, y_coords in lines_m: - fig.plot(x=x_coords, y=y_coords, **args_m) - # middle corner - fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) - - # ............................................................................. - # letter T - # ............................................................................. - # red curved horizontal line - fig.plot( - x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red, perspective=True - ) - # vertical endings of curved horizontal line - args_vert = {"y": [-1.5, -2.5], "pen": f"9p,{color_bg}", "perspective": True} - fig.plot(x=[-1.05, -1.05], **args_vert) - fig.plot(x=[1.05, 1.05], **args_vert) - # arrow head as inverse triangle with pen for space to blue circle / hexagon - fig.plot( - x=0, - y=-3.55, - style="i1.1c", - fill=color_red, - pen=f"3p,{color_bg}", - perspective=True, - ) - # arrow tail - fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) - - # margin around shape for black_white in dark_mode - Needed ??? - if black_white and dark_mode: - fig.plot( - x=0, - y=0, - style=f"{symbol}{diameter + diameter_add}c", - pen=f"1p,{color_dark}", - no_clip=True, - perspective=True, - ) - - # ............................................................................. - # Add wordmark "PyGMT" - # ............................................................................. - if wordmark: - text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" - fig.text(text=text_wm, no_clip=True, **args_text_wm) - - # ............................................................................. - # Save - # ............................................................................. - fig_name_logo = "pygmt_logo" - fig.savefig(fname=f"{fig_name_logo}.eps") - - return fig_name_logo, color_bg - - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # End of subfunction - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - # ----------------------------------------------------------------------------- - # Replot and add to existing Figure instance - # ----------------------------------------------------------------------------- - fig_name_logo, color_bg = create_logo() - - if box is None: - box = f"+g{color_bg}" - - # Use parameters of pygmt.Figure.image - self.image(imagefile=f"{fig_name_logo}.eps", position=position, box=box) - - Path.unlink(f"{fig_name_logo}.eps") +""" +pygmtlogo - Create and plot the PyGMT logo. +""" + +from pathlib import Path + +import pygmt + + +def pygmtlogo( # noqa: PLR0915 + self, + black_white=False, + dark_mode=True, + hex_shape=False, + wordmark=True, + orientation="horizontal", # "horizontal" | "vertical" + position="jRT+o0.1c+w5c", # -> use position parameter of Figure.image + box=None, # -> use box parameter of Figure.image +): + """ + Plot the PyGMT logo. + + Parameters + ---------- + + black_white : Draw in black and white. + ``False`` use colors for Python (blue and yellow) and GMT (red) [Default] or + ``True`` for black and white. + dark_mode : Use dark background. + ``False`` white or ``True`` darkgray [Default]. + hex_shape : Use hexagon shape. + ``False`` circle [Default] or ``True`` hexagon. + wordmark : add the wordmark "PyGMT". + ``True`` with wordmark [Default] or ``False`` without wordmark. + orientation : Orientation of the wordmark. + ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. + """ + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # Start of subfunction + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + def create_logo( # noqa: PLR0915 + black_white=black_white, + dark_mode=dark_mode, + hex_shape=hex_shape, + wordmark=wordmark, + orientation=orientation, + ): + # ----------------------------------------------------------------------------- + # Helpful definitions + # ----------------------------------------------------------------------------- + size = 4 + region = [-size, size] * 2 + + xy_yellow_1 = 2.65 + xy_yellow_2 = 1.3 + + no_line = "cyan@100" + no_fill = f"+g{no_line}" + + # Rotation around z (vertical) axis placed in the center + # Has to be applied to each plotting command, up on second call set to True + # Do NOT rotated initial basemap + angle_rot = 30 # degrees + perspective = f"{angle_rot}+w0/0" + + # ----------------------------------------------------------------------------- + # Define colors + # ----------------------------------------------------------------------------- + color_dark = "gray20" + color_light = "white" + + # visual + color_blue = "48/105/152" # Python blue + color_yellow = "255/212/59" # Python yellow + color_red = "238/86/52" # GMT red + if black_white: + color_blue = color_yellow = color_red = color_light + if not dark_mode: + color_blue = color_yellow = color_red = color_dark + + # background and wordmark + color_bg = color_dark + color_py = color_yellow + color_gmt = color_light + if not dark_mode: + color_bg = color_light + color_py = color_blue + color_gmt = color_dark + + # ----------------------------------------------------------------------------- + # Define shape + # ----------------------------------------------------------------------------- + symbol = "c" # circle + diameter = 7.5 + diameter_add = 0.5 + if hex_shape: + symbol = "h" # hexagon + diameter = 8.6 + diameter_add = 0.6 + + # ----------------------------------------------------------------------------- + # Define wordmark + # ----------------------------------------------------------------------------- + font = "AvantGarde-Book" + match orientation: + case "vertical": + args_text_wm = { + "x": 0, + "y": -5, + "justify": "CT", + "font": f"2.5c,{font}", + } + case "horizontal": + args_text_wm = { + "x": 6, + "y": 0, + "justify": "LM", + "font": f"8c,{font}", + } + + # ----------------------------------------------------------------------------- + # Start plotting + # ----------------------------------------------------------------------------- + fig = pygmt.Figure() + pygmt.config(MAP_FRAME_PEN=no_line) + fig.basemap( + region=region, + projection=f"X{size * 2}c", + frame=no_fill, + ) + + # ............................................................................. + # blue circle / hexagon for Earth + # ............................................................................. + fig.plot( + x=0, + y=0, + style=f"{symbol}{diameter}c", + pen=f"15p,{color_blue}", + fill=color_bg, + no_clip=True, + perspective=perspective, + ) + + # ............................................................................. + # yellow lines for compass + # ............................................................................. + args_yellow = {"pen": f"5p,{color_yellow}", "perspective": True} + # horizontal yellow line + fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) + # diagonal yellow lines + lines_diagonal = [ + ([-xy_yellow_1, -xy_yellow_2], [xy_yellow_1, xy_yellow_2]), # upper left + ([xy_yellow_2, xy_yellow_1], [-xy_yellow_2, -xy_yellow_1]), # lower right + ([-xy_yellow_1, -xy_yellow_2], [-xy_yellow_1, -xy_yellow_2]), # lower left + ([xy_yellow_2, xy_yellow_1], [xy_yellow_2, xy_yellow_1]), # upper right + ] + for x_coords, y_coords in lines_diagonal: + fig.plot(x=x_coords, y=y_coords, **args_yellow) + + # ............................................................................. + # letter G + # ............................................................................. + # horizontal red line + fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}", perspective=True) + # red ring sector + fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red, perspective=True) + # space between yellow lines and ring sector + fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg, perspective=True) + # vertical yellow line + fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}", perspective=True) + # cover yellow line in lower part of the ring sector + fig.plot( + x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red, perspective=True + ) + + # ............................................................................. + # upper vertical red line + # ............................................................................. + # space between red line and blue circle / hexagon + fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}", perspective=True) + # red line + fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}", perspective=True) + + # ............................................................................. + # letter M + # ............................................................................. + # space between letter M and yellow line at the right side + # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") + fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) + # lines with small distance to horizontal line of letter G + args_m = {"pen": f"10p,{color_red}", "perspective": True} + lines_m = [ + ([0.33, 0.90], [1.527, 1.00]), # diagonal left + ([0.90, 1.43], [1.00, 1.527]), # diagonal right + ([0.285, 0.285], [0.30, 1.65]), # vertical left + ([1.47, 1.47], [0.30, 1.65]), # vertical right + ] + for x_coords, y_coords in lines_m: + fig.plot(x=x_coords, y=y_coords, **args_m) + # middle corner + fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) + + # ............................................................................. + # letter T + # ............................................................................. + # red curved horizontal line + fig.plot( + x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red, perspective=True + ) + # vertical endings of curved horizontal line + args_vert = {"y": [-1.5, -2.5], "pen": f"9p,{color_bg}", "perspective": True} + fig.plot(x=[-1.05, -1.05], **args_vert) + fig.plot(x=[1.05, 1.05], **args_vert) + # arrow head as inverse triangle with pen for space to blue circle / hexagon + fig.plot( + x=0, + y=-3.55, + style="i1.1c", + fill=color_red, + pen=f"3p,{color_bg}", + perspective=True, + ) + # arrow tail + fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) + + # margin around shape for black_white in dark_mode - Needed ??? + if black_white and dark_mode: + fig.plot( + x=0, + y=0, + style=f"{symbol}{diameter + diameter_add}c", + pen=f"1p,{color_dark}", + no_clip=True, + perspective=True, + ) + + # ............................................................................. + # Add wordmark "PyGMT" + # ............................................................................. + if wordmark: + text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" + fig.text(text=text_wm, no_clip=True, **args_text_wm) + + # ............................................................................. + # Save + # ............................................................................. + fig_name_logo = "pygmt_logo" + fig.savefig(fname=f"{fig_name_logo}.eps") + + return fig_name_logo, color_bg + + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # End of subfunction + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + # ----------------------------------------------------------------------------- + # Replot and add to existing Figure instance + # ----------------------------------------------------------------------------- + fig_name_logo, color_bg = create_logo() + + if box is None: + box = f"+g{color_bg}" + + # Use parameters of pygmt.Figure.image + self.image(imagefile=f"{fig_name_logo}.eps", position=position, box=box) + + Path.unlink(f"{fig_name_logo}.eps") From 2132e5eb7a4d13b24211d0b7f23ab1f34d9dd52e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:43:31 +0100 Subject: [PATCH 105/379] Add tests --- pygmt/tests/test_pygmtlogo.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 pygmt/tests/test_pygmtlogo.py diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py new file mode 100755 index 00000000000..0084d83d146 --- /dev/null +++ b/pygmt/tests/test_pygmtlogo.py @@ -0,0 +1,28 @@ +""" +Test Figure.pygmtlogo. +""" + +import pytest +from pygmt import Figure + + +@pytest.mark.benchmark +@pytest.mark.mpl_image_compare +def test_pylogo(): + """ + Plot the PyGMT logo as a stand-alone plot. + """ + fig = Figure() + fig.pygmtlogo() + return fig + + +@pytest.mark.mpl_image_compare +def test_pylogo_on_a_map(): + """ + Plot the PyGMT logo at the lower right corner of a map. + """ + fig = Figure() + fig.basemap(region=[-90, -70, 0, 20], projection="M15c", frame=True) + fig.pygmtlogo(position="jBR+o0.25c/0.25c+w7.5c", box=True) + return fig From 438a10081aec05d360080e27645b03d4a1732182 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:44:29 +0100 Subject: [PATCH 106/379] Follow code style --- pygmt/tests/test_pygmtlogo.py | 56 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index 0084d83d146..552a5f80125 100755 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -1,28 +1,28 @@ -""" -Test Figure.pygmtlogo. -""" - -import pytest -from pygmt import Figure - - -@pytest.mark.benchmark -@pytest.mark.mpl_image_compare -def test_pylogo(): - """ - Plot the PyGMT logo as a stand-alone plot. - """ - fig = Figure() - fig.pygmtlogo() - return fig - - -@pytest.mark.mpl_image_compare -def test_pylogo_on_a_map(): - """ - Plot the PyGMT logo at the lower right corner of a map. - """ - fig = Figure() - fig.basemap(region=[-90, -70, 0, 20], projection="M15c", frame=True) - fig.pygmtlogo(position="jBR+o0.25c/0.25c+w7.5c", box=True) - return fig +""" +Test Figure.pygmtlogo. +""" + +import pytest +from pygmt import Figure + + +@pytest.mark.benchmark +@pytest.mark.mpl_image_compare +def test_pylogo(): + """ + Plot the PyGMT logo as a stand-alone plot. + """ + fig = Figure() + fig.pygmtlogo() + return fig + + +@pytest.mark.mpl_image_compare +def test_pylogo_on_a_map(): + """ + Plot the PyGMT logo at the lower right corner of a map. + """ + fig = Figure() + fig.basemap(region=[-90, -70, 0, 20], projection="M15c", frame=True) + fig.pygmtlogo(position="jBR+o0.25c/0.25c+w7.5c", box=True) + return fig From cb854e383e8354b4fb3e6ab3985b45d4b5885ba3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:46:56 +0100 Subject: [PATCH 107/379] Update docs --- examples/gallery/embellishments/pygmt_logo.py | 14 +------------- pygmt/src/pygmtlogo.py | 1 + 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 34b8eee194e..282a1d7631e 100755 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -3,19 +3,7 @@ ========== The PyGMT logo coded in Python using PyGMT. The design of the logo is kindly provided by `@sfrooti `_. The logo consists of a visual and the -wordmark "PyGMT". There are different versions available: - -- ``black_white``: draw in black and white. - ``False`` colors for Python (blue and yellow) and GMT (red) [Default] or ``True`` - for black and white. -- ``dark_mode``: use dark background. - ``False`` white or ``True`` darkgray / gray20 [Default]. -- ``hex_shape``: use hexagon shape. - ``False`` circle [Default] or ``True`` hexagon. -- ``wordmark``: add the wordmark "PyGMT". - ``True`` with wordmark [Default] or ``False`` without wordmark. -- ``orientation``: orientation of the wordmark. - ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. +wordmark "PyGMT". """ import pygmt diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 5a1a1bd32eb..0328f6af159 100755 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -1,5 +1,6 @@ """ pygmtlogo - Create and plot the PyGMT logo. +The design of the logo is kindly provided by `@sfrooti `_. """ from pathlib import Path From 3d40b6a5a9b169864e8f7d6497e734a3b6d2aec4 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:49:46 +0100 Subject: [PATCH 108/379] Remove exectuion permission --- examples/gallery/embellishments/pygmt_logo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py old mode 100755 new mode 100644 From d81c07781706b245872fbf84a3b4a25ef4467819 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:50:28 +0100 Subject: [PATCH 109/379] Remove exection permission --- pygmt/src/pygmtlogo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 pygmt/src/pygmtlogo.py diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py old mode 100755 new mode 100644 From 26962345f16b5867f53227cfd4f926236b1970c9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 21:51:02 +0100 Subject: [PATCH 110/379] Remove execution permission --- pygmt/tests/test_pygmtlogo.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 pygmt/tests/test_pygmtlogo.py diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py old mode 100755 new mode 100644 From c9262ccaac281d469329b143c39d64498e89f0dd Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 22:15:52 +0100 Subject: [PATCH 111/379] Update docstrings --- pygmt/src/pygmtlogo.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 0328f6af159..6b6893d0b2c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -20,21 +20,26 @@ def pygmtlogo( # noqa: PLR0915 ): """ Plot the PyGMT logo. + The design of the logo is kindly provided by `@sfrooti `_. Parameters ---------- - black_white : Draw in black and white. - ``False`` use colors for Python (blue and yellow) and GMT (red) [Default] or - ``True`` for black and white. - dark_mode : Use dark background. - ``False`` white or ``True`` darkgray [Default]. - hex_shape : Use hexagon shape. - ``False`` circle [Default] or ``True`` hexagon. - wordmark : add the wordmark "PyGMT". - ``True`` with wordmark [Default] or ``False`` without wordmark. - orientation : Orientation of the wordmark. - ``"horizontal"`` at the right [Default] or ``"vertical"`` at the bottom. + black_white : bool + Draw in black and white. ``False`` colors for Python (blue and yellow) + and GMT (red) are used [Default]. Use ``True`` for black and white. + dark_mode : bool + Use dark background. ``True`` leads to dark mode [Default] and ``False`` + to light mode. + hex_shape : bool + Use a hexagon shape. ``False`` leads to a circle shape [Default]. Use + ``True`` for a hexagon shape. + wordmark : bool + Add the wordmark "PyGMT". ``True`` adds the wordmark [Default] and ``False`` + to skipes it. + orientation : str + Orientation of the wordmark. Use ``"horizontal"`` to place the wordmark at + the right side [Default] or ``"vertical"`` to place it below the visual. """ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Start of subfunction From 5999c5159b2ee1dbf2526056105d23a9f9c0dde3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 22:38:43 +0100 Subject: [PATCH 112/379] Follow rules for variable names and use no space between consonants --- examples/gallery/embellishments/pygmt_logo.py | 26 ++++++++-------- pygmt/src/pygmtlogo.py | 30 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 282a1d7631e..81eae400eff 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -34,48 +34,48 @@ fig.logo() # GMT logo fig.pygmtlogo() -fig.pygmtlogo(dark_mode=False, hex_shape=True, position="jTL+o0.1c+w4c", box=False) -fig.pygmtlogo(dark_mode=False, position="jTC+o0c/2c+w5c", box="+p1p,black") +fig.pygmtlogo(darkmode=False, hexshape=True, position="jTL+o0.1c+w4c", box=False) +fig.pygmtlogo(darkmode=False, position="jTC+o0c/2c+w5c", box="+p1p,black") fig.pygmtlogo( - black_white=True, - dark_mode=False, + blackwhite=True, + darkmode=False, wordmark=False, position="jTL+o0.5c/2c+w1.5c", box=False, ) fig.pygmtlogo( - black_white=True, - hex_shape=True, + blackwhite=True, + hexshape=True, wordmark=False, position="jTR+o0.5c/2c+w1.5c", box=False, ) -fig.pygmtlogo(black_white=True, orientation="vertical", position="jMC+w2c") +fig.pygmtlogo(blackwhite=True, orientation="vertical", position="jMC+w2c") """ fig.pygmtlogo(wordmark=False, position="jML+w2c", box=True) fig.pygmtlogo( - dark_mode=False, + darkmode=False, wordmark=False, position="jBL+w2c", box="+p1p,black", ) fig.pygmtlogo( - black_white=True, + blackwhite=True, orientation="vertical", position="jMC+w2c", box="+p1p,blue+gcyan", ) fig.pygmtlogo( - black_white=True, - hex_shape=True, + blackwhite=True, + hexshape=True, orientation="vertical", position="jBC+w2c", box="+ggray20", ) -fig.pygmtlogo(hex_shape=True, wordmark=False, position="jMR+w2c") -fig.pygmtlogo(dark_mode=False, hex_shape=True, wordmark=False, position="jBR+w2c") +fig.pygmtlogo(hexshape=True, wordmark=False, position="jMR+w2c") +fig.pygmtlogo(darkmode=False, hexshape=True, wordmark=False, position="jBR+w2c") """ fig.show() diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6b6893d0b2c..164d2b2d3b0 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -10,9 +10,9 @@ def pygmtlogo( # noqa: PLR0915 self, - black_white=False, - dark_mode=True, - hex_shape=False, + blackwhite=False, + darkmode=True, + hexshape=False, wordmark=True, orientation="horizontal", # "horizontal" | "vertical" position="jRT+o0.1c+w5c", # -> use position parameter of Figure.image @@ -25,13 +25,13 @@ def pygmtlogo( # noqa: PLR0915 Parameters ---------- - black_white : bool + blackwhite : bool Draw in black and white. ``False`` colors for Python (blue and yellow) and GMT (red) are used [Default]. Use ``True`` for black and white. - dark_mode : bool + darkmode : bool Use dark background. ``True`` leads to dark mode [Default] and ``False`` to light mode. - hex_shape : bool + hexshape : bool Use a hexagon shape. ``False`` leads to a circle shape [Default]. Use ``True`` for a hexagon shape. wordmark : bool @@ -46,9 +46,9 @@ def pygmtlogo( # noqa: PLR0915 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def create_logo( # noqa: PLR0915 - black_white=black_white, - dark_mode=dark_mode, - hex_shape=hex_shape, + blackwhite=blackwhite, + darkmode=darkmode, + hexshape=hexshape, wordmark=wordmark, orientation=orientation, ): @@ -80,16 +80,16 @@ def create_logo( # noqa: PLR0915 color_blue = "48/105/152" # Python blue color_yellow = "255/212/59" # Python yellow color_red = "238/86/52" # GMT red - if black_white: + if blackwhite: color_blue = color_yellow = color_red = color_light - if not dark_mode: + if not darkmode: color_blue = color_yellow = color_red = color_dark # background and wordmark color_bg = color_dark color_py = color_yellow color_gmt = color_light - if not dark_mode: + if not darkmode: color_bg = color_light color_py = color_blue color_gmt = color_dark @@ -100,7 +100,7 @@ def create_logo( # noqa: PLR0915 symbol = "c" # circle diameter = 7.5 diameter_add = 0.5 - if hex_shape: + if hexshape: symbol = "h" # hexagon diameter = 8.6 diameter_add = 0.6 @@ -231,8 +231,8 @@ def create_logo( # noqa: PLR0915 # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) - # margin around shape for black_white in dark_mode - Needed ??? - if black_white and dark_mode: + # margin around shape for blackwhite=True in darkmode=True + if blackwhite and darkmode: fig.plot( x=0, y=0, From 4121569273d14f65a5c608794113dff7fd001fd9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 22:42:04 +0100 Subject: [PATCH 113/379] Reduce galler example --- examples/gallery/embellishments/pygmt_logo.py | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 81eae400eff..32824baffc6 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -53,29 +53,6 @@ ) fig.pygmtlogo(blackwhite=True, orientation="vertical", position="jMC+w2c") -""" -fig.pygmtlogo(wordmark=False, position="jML+w2c", box=True) -fig.pygmtlogo( - darkmode=False, - wordmark=False, - position="jBL+w2c", - box="+p1p,black", -) -fig.pygmtlogo( - blackwhite=True, - orientation="vertical", - position="jMC+w2c", - box="+p1p,blue+gcyan", -) -fig.pygmtlogo( - blackwhite=True, - hexshape=True, - orientation="vertical", - position="jBC+w2c", - box="+ggray20", -) -fig.pygmtlogo(hexshape=True, wordmark=False, position="jMR+w2c") -fig.pygmtlogo(darkmode=False, hexshape=True, wordmark=False, position="jBR+w2c") -""" - fig.show() + +# sphinx_gallery_thumbnail_number = 3 From 16eb3dc717ca298d8dddf220b8a50017c4ce3244 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Mar 2025 23:09:01 +0100 Subject: [PATCH 114/379] Expand tests --- pygmt/tests/test_pygmtlogo.py | 42 +++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index 552a5f80125..fb7e8f0fd61 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -10,9 +10,10 @@ @pytest.mark.mpl_image_compare def test_pylogo(): """ - Plot the PyGMT logo as a stand-alone plot. + Plot the PyGMT logo using the default settings. """ fig = Figure() + fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) fig.pygmtlogo() return fig @@ -20,9 +21,42 @@ def test_pylogo(): @pytest.mark.mpl_image_compare def test_pylogo_on_a_map(): """ - Plot the PyGMT logo at the lower right corner of a map. + Plot the PyGMT logo and adjust the position, offset, and size. """ fig = Figure() - fig.basemap(region=[-90, -70, 0, 20], projection="M15c", frame=True) - fig.pygmtlogo(position="jBR+o0.25c/0.25c+w7.5c", box=True) + fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) + fig.pygmtlogo(position="jMC+o0.25c/0.25c+w7.5c", box=True) + return fig + + +@pytest.mark.mpl_image_compare +def test_pylogo_no_wordmark(): + """ + Plot the PyGMT logo without wordmark. + """ + fig = Figure() + fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) + fig.pygmtlogo(wordmark=False) + return fig + + +@pytest.mark.mpl_image_compare +def test_pylogo_lightmode(): + """ + Plot the PyGMT logo in light mode. + """ + fig = Figure() + fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) + fig.pygmtlogo(darkmode=False) + return fig + + +@pytest.mark.mpl_image_compare +def test_pylogo_vertical(): + """ + Plot the PyGMT logo with vertical orientation of the wordmark. + """ + fig = Figure() + fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) + fig.pygmtlogo(orientation="vertical") return fig From 6d71dc378c6a95f8497a87954004aa6888b4dfdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 17 Mar 2025 16:33:00 +0100 Subject: [PATCH 115/379] Set box default to None Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 164d2b2d3b0..e8d51ba2045 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -15,7 +15,7 @@ def pygmtlogo( # noqa: PLR0915 hexshape=False, wordmark=True, orientation="horizontal", # "horizontal" | "vertical" - position="jRT+o0.1c+w5c", # -> use position parameter of Figure.image + position=None, # -> use position parameter of Figure.image box=None, # -> use box parameter of Figure.image ): """ From e8c693ebfee1c6e9bdd5e02dd410aa921c1bacd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 17 Mar 2025 16:33:25 +0100 Subject: [PATCH 116/379] Plot without setting up basemap Co-authored-by: Dongdong Tian --- examples/gallery/embellishments/pygmt_logo.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 32824baffc6..2f98ac3a4cb 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -9,11 +9,7 @@ import pygmt fig = pygmt.Figure() -pygmt.config(MAP_FRAME_PEN="cyan@100") -fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame="+gcyan@100") - -fig.pygmtlogo(position="jMC+w10c", wordmark=False, box=False) - +fig.pygmtlogo() fig.show() # %% From 1a2ca98c535db85bff5b1bd3d307ce529c16aaf9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 17 Mar 2025 16:41:10 +0100 Subject: [PATCH 117/379] Add more parameters --- pygmt/src/pygmtlogo.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e8d51ba2045..6631fcdb14a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -17,6 +17,11 @@ def pygmtlogo( # noqa: PLR0915 orientation="horizontal", # "horizontal" | "vertical" position=None, # -> use position parameter of Figure.image box=None, # -> use box parameter of Figure.image + projection=None, + region=None, + verbose=None, + panel=None, + transparency=None, ): """ Plot the PyGMT logo. @@ -270,6 +275,15 @@ def create_logo( # noqa: PLR0915 box = f"+g{color_bg}" # Use parameters of pygmt.Figure.image - self.image(imagefile=f"{fig_name_logo}.eps", position=position, box=box) + self.image( + imagefile=f"{fig_name_logo}.eps", + position=position, + box=box, + projection=projection, + region=region, + verbose=verbose, + panel=panel, + transparency=transparency, + ) Path.unlink(f"{fig_name_logo}.eps") From d716bd50d1cf66e419aa38e48057dcac60856dc0 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 17 Mar 2025 16:42:35 +0100 Subject: [PATCH 118/379] Exclude PLR0913 --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6631fcdb14a..59b4f06c7d0 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -8,7 +8,7 @@ import pygmt -def pygmtlogo( # noqa: PLR0915 +def pygmtlogo( # noqa: PLR0915, PLR0913 self, blackwhite=False, darkmode=True, From 59dff816f4516318bd72cfb225ea138ea14779c4 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 17 Mar 2025 16:43:19 +0100 Subject: [PATCH 119/379] Update tests --- pygmt/tests/test_pygmtlogo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index fb7e8f0fd61..a632ac13427 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -13,7 +13,6 @@ def test_pylogo(): Plot the PyGMT logo using the default settings. """ fig = Figure() - fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) fig.pygmtlogo() return fig From d35c44522217b13edf82ecb088ef191baaf54877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:32:39 +0100 Subject: [PATCH 120/379] Use default position=Non Co-authored-by: Dongdong Tian --- examples/gallery/embellishments/pygmt_logo.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 2f98ac3a4cb..85a94ad20ed 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -15,10 +15,7 @@ # %% fig = pygmt.Figure() -pygmt.config(MAP_FRAME_PEN="cyan@100") -fig.basemap(region=[-5, 5, -5, 5], projection="X10c/2c", frame="+gcyan@100") - -fig.pygmtlogo(dark_mode=False, position="jMC+w10c") +fig.pygmtlogo(darkmode=False) fig.show() From 13306c8351b9d15364cd85bf9cff1e817493a8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:39:08 +0100 Subject: [PATCH 121/379] Remove blank line --- examples/gallery/embellishments/pygmt_logo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 85a94ad20ed..13d3955b900 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -16,7 +16,6 @@ fig = pygmt.Figure() fig.pygmtlogo(darkmode=False) - fig.show() # %% From 78ea05a68d771e8634c2ad37d14809de8e0fe541 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 18 Mar 2025 22:38:00 +0100 Subject: [PATCH 122/379] Move function create_logo out of function pygmtlogo --- pygmt/src/pygmtlogo.py | 452 +++++++++++++++++++++-------------------- 1 file changed, 229 insertions(+), 223 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 59b4f06c7d0..a904bf5a8ef 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -8,23 +8,15 @@ import pygmt -def pygmtlogo( # noqa: PLR0915, PLR0913 - self, +def create_logo( # noqa: PLR0915 blackwhite=False, darkmode=True, hexshape=False, wordmark=True, - orientation="horizontal", # "horizontal" | "vertical" - position=None, # -> use position parameter of Figure.image - box=None, # -> use box parameter of Figure.image - projection=None, - region=None, - verbose=None, - panel=None, - transparency=None, + orientation="horizontal", ): """ - Plot the PyGMT logo. + Creat the PyGMT logo. The design of the logo is kindly provided by `@sfrooti `_. Parameters @@ -46,235 +38,249 @@ def pygmtlogo( # noqa: PLR0915, PLR0913 Orientation of the wordmark. Use ``"horizontal"`` to place the wordmark at the right side [Default] or ``"vertical"`` to place it below the visual. """ - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # Start of subfunction - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - def create_logo( # noqa: PLR0915 - blackwhite=blackwhite, - darkmode=darkmode, - hexshape=hexshape, - wordmark=wordmark, - orientation=orientation, - ): - # ----------------------------------------------------------------------------- - # Helpful definitions - # ----------------------------------------------------------------------------- - size = 4 - region = [-size, size] * 2 - - xy_yellow_1 = 2.65 - xy_yellow_2 = 1.3 - - no_line = "cyan@100" - no_fill = f"+g{no_line}" - - # Rotation around z (vertical) axis placed in the center - # Has to be applied to each plotting command, up on second call set to True - # Do NOT rotated initial basemap - angle_rot = 30 # degrees - perspective = f"{angle_rot}+w0/0" - - # ----------------------------------------------------------------------------- - # Define colors - # ----------------------------------------------------------------------------- - color_dark = "gray20" - color_light = "white" - - # visual - color_blue = "48/105/152" # Python blue - color_yellow = "255/212/59" # Python yellow - color_red = "238/86/52" # GMT red - if blackwhite: - color_blue = color_yellow = color_red = color_light - if not darkmode: - color_blue = color_yellow = color_red = color_dark - - # background and wordmark - color_bg = color_dark - color_py = color_yellow - color_gmt = color_light + # ----------------------------------------------------------------------------- + # Helpful definitions + # ----------------------------------------------------------------------------- + size = 4 + region = [-size, size] * 2 + + xy_yellow_1 = 2.65 + xy_yellow_2 = 1.3 + + no_line = "cyan@100" + no_fill = f"+g{no_line}" + + # Rotation around z (vertical) axis placed in the center + # Has to be applied to each plotting command, up on second call set to True + # Do NOT rotated initial basemap + angle_rot = 30 # degrees + perspective = f"{angle_rot}+w0/0" + + # ----------------------------------------------------------------------------- + # Define colors + # ----------------------------------------------------------------------------- + color_dark = "gray20" + color_light = "white" + + # visual + color_blue = "48/105/152" # Python blue + color_yellow = "255/212/59" # Python yellow + color_red = "238/86/52" # GMT red + if blackwhite: + color_blue = color_yellow = color_red = color_light if not darkmode: - color_bg = color_light - color_py = color_blue - color_gmt = color_dark - - # ----------------------------------------------------------------------------- - # Define shape - # ----------------------------------------------------------------------------- - symbol = "c" # circle - diameter = 7.5 - diameter_add = 0.5 - if hexshape: - symbol = "h" # hexagon - diameter = 8.6 - diameter_add = 0.6 - - # ----------------------------------------------------------------------------- - # Define wordmark - # ----------------------------------------------------------------------------- - font = "AvantGarde-Book" - match orientation: - case "vertical": - args_text_wm = { - "x": 0, - "y": -5, - "justify": "CT", - "font": f"2.5c,{font}", - } - case "horizontal": - args_text_wm = { - "x": 6, - "y": 0, - "justify": "LM", - "font": f"8c,{font}", - } - - # ----------------------------------------------------------------------------- - # Start plotting - # ----------------------------------------------------------------------------- - fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN=no_line) - fig.basemap( - region=region, - projection=f"X{size * 2}c", - frame=no_fill, - ) + color_blue = color_yellow = color_red = color_dark + + # background and wordmark + color_bg = color_dark + color_py = color_yellow + color_gmt = color_light + if not darkmode: + color_bg = color_light + color_py = color_blue + color_gmt = color_dark + + # ----------------------------------------------------------------------------- + # Define shape + # ----------------------------------------------------------------------------- + symbol = "c" # circle + diameter = 7.5 + diameter_add = 0.5 + if hexshape: + symbol = "h" # hexagon + diameter = 8.6 + diameter_add = 0.6 + + # ----------------------------------------------------------------------------- + # Define wordmark + # ----------------------------------------------------------------------------- + font = "AvantGarde-Book" + match orientation: + case "vertical": + args_text_wm = { + "x": 0, + "y": -5, + "justify": "CT", + "font": f"2.5c,{font}", + } + case "horizontal": + args_text_wm = { + "x": 6, + "y": 0, + "justify": "LM", + "font": f"8c,{font}", + } + + # ----------------------------------------------------------------------------- + # Start plotting + # ----------------------------------------------------------------------------- + fig = pygmt.Figure() + pygmt.config(MAP_FRAME_PEN=no_line) + fig.basemap( + region=region, + projection=f"X{size * 2}c", + frame=no_fill, + ) + + # ............................................................................. + # blue circle / hexagon for Earth + # ............................................................................. + fig.plot( + x=0, + y=0, + style=f"{symbol}{diameter}c", + pen=f"15p,{color_blue}", + fill=color_bg, + no_clip=True, + perspective=perspective, + ) + + # ............................................................................. + # yellow lines for compass + # ............................................................................. + args_yellow = {"pen": f"5p,{color_yellow}", "perspective": True} + # horizontal yellow line + fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) + # diagonal yellow lines + lines_diagonal = [ + ([-xy_yellow_1, -xy_yellow_2], [xy_yellow_1, xy_yellow_2]), # upper left + ([xy_yellow_2, xy_yellow_1], [-xy_yellow_2, -xy_yellow_1]), # lower right + ([-xy_yellow_1, -xy_yellow_2], [-xy_yellow_1, -xy_yellow_2]), # lower left + ([xy_yellow_2, xy_yellow_1], [xy_yellow_2, xy_yellow_1]), # upper right + ] + for x_coords, y_coords in lines_diagonal: + fig.plot(x=x_coords, y=y_coords, **args_yellow) + + # ............................................................................. + # letter G + # ............................................................................. + # horizontal red line + fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}", perspective=True) + # red ring sector + fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red, perspective=True) + # space between yellow lines and ring sector + fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg, perspective=True) + # vertical yellow line + fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}", perspective=True) + # cover yellow line in lower part of the ring sector + fig.plot(x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red, perspective=True) + + # ............................................................................. + # upper vertical red line + # ............................................................................. + # space between red line and blue circle / hexagon + fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}", perspective=True) + # red line + fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}", perspective=True) + + # ............................................................................. + # letter M + # ............................................................................. + # space between letter M and yellow line at the right side + # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") + fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) + # lines with small distance to horizontal line of letter G + args_m = {"pen": f"10p,{color_red}", "perspective": True} + lines_m = [ + ([0.33, 0.90], [1.527, 1.00]), # diagonal left + ([0.90, 1.43], [1.00, 1.527]), # diagonal right + ([0.285, 0.285], [0.30, 1.65]), # vertical left + ([1.47, 1.47], [0.30, 1.65]), # vertical right + ] + for x_coords, y_coords in lines_m: + fig.plot(x=x_coords, y=y_coords, **args_m) + # middle corner + fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) - # ............................................................................. - # blue circle / hexagon for Earth - # ............................................................................. + # ............................................................................. + # letter T + # ............................................................................. + # red curved horizontal line + fig.plot(x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red, perspective=True) + # vertical endings of curved horizontal line + args_vert = {"y": [-1.5, -2.5], "pen": f"9p,{color_bg}", "perspective": True} + fig.plot(x=[-1.05, -1.05], **args_vert) + fig.plot(x=[1.05, 1.05], **args_vert) + # arrow head as inverse triangle with pen for space to blue circle / hexagon + fig.plot( + x=0, + y=-3.55, + style="i1.1c", + fill=color_red, + pen=f"3p,{color_bg}", + perspective=True, + ) + # arrow tail + fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) + + # margin around shape for blackwhite=True in darkmode=True + if blackwhite and darkmode: fig.plot( x=0, y=0, - style=f"{symbol}{diameter}c", - pen=f"15p,{color_blue}", - fill=color_bg, + style=f"{symbol}{diameter + diameter_add}c", + pen=f"1p,{color_dark}", no_clip=True, - perspective=perspective, + perspective=True, ) - # ............................................................................. - # yellow lines for compass - # ............................................................................. - args_yellow = {"pen": f"5p,{color_yellow}", "perspective": True} - # horizontal yellow line - fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) - # diagonal yellow lines - lines_diagonal = [ - ([-xy_yellow_1, -xy_yellow_2], [xy_yellow_1, xy_yellow_2]), # upper left - ([xy_yellow_2, xy_yellow_1], [-xy_yellow_2, -xy_yellow_1]), # lower right - ([-xy_yellow_1, -xy_yellow_2], [-xy_yellow_1, -xy_yellow_2]), # lower left - ([xy_yellow_2, xy_yellow_1], [xy_yellow_2, xy_yellow_1]), # upper right - ] - for x_coords, y_coords in lines_diagonal: - fig.plot(x=x_coords, y=y_coords, **args_yellow) - - # ............................................................................. - # letter G - # ............................................................................. - # horizontal red line - fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}", perspective=True) - # red ring sector - fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red, perspective=True) - # space between yellow lines and ring sector - fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg, perspective=True) - # vertical yellow line - fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}", perspective=True) - # cover yellow line in lower part of the ring sector - fig.plot( - x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red, perspective=True - ) + # ............................................................................. + # Add wordmark "PyGMT" + # ............................................................................. + if wordmark: + text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" + fig.text(text=text_wm, no_clip=True, **args_text_wm) - # ............................................................................. - # upper vertical red line - # ............................................................................. - # space between red line and blue circle / hexagon - fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}", perspective=True) - # red line - fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}", perspective=True) - - # ............................................................................. - # letter M - # ............................................................................. - # space between letter M and yellow line at the right side - # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") - fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) - # lines with small distance to horizontal line of letter G - args_m = {"pen": f"10p,{color_red}", "perspective": True} - lines_m = [ - ([0.33, 0.90], [1.527, 1.00]), # diagonal left - ([0.90, 1.43], [1.00, 1.527]), # diagonal right - ([0.285, 0.285], [0.30, 1.65]), # vertical left - ([1.47, 1.47], [0.30, 1.65]), # vertical right - ] - for x_coords, y_coords in lines_m: - fig.plot(x=x_coords, y=y_coords, **args_m) - # middle corner - fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) - - # ............................................................................. - # letter T - # ............................................................................. - # red curved horizontal line - fig.plot( - x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red, perspective=True - ) - # vertical endings of curved horizontal line - args_vert = {"y": [-1.5, -2.5], "pen": f"9p,{color_bg}", "perspective": True} - fig.plot(x=[-1.05, -1.05], **args_vert) - fig.plot(x=[1.05, 1.05], **args_vert) - # arrow head as inverse triangle with pen for space to blue circle / hexagon - fig.plot( - x=0, - y=-3.55, - style="i1.1c", - fill=color_red, - pen=f"3p,{color_bg}", - perspective=True, - ) - # arrow tail - fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) - - # margin around shape for blackwhite=True in darkmode=True - if blackwhite and darkmode: - fig.plot( - x=0, - y=0, - style=f"{symbol}{diameter + diameter_add}c", - pen=f"1p,{color_dark}", - no_clip=True, - perspective=True, - ) - - # ............................................................................. - # Add wordmark "PyGMT" - # ............................................................................. - if wordmark: - text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" - fig.text(text=text_wm, no_clip=True, **args_text_wm) - - # ............................................................................. - # Save - # ............................................................................. - fig_name_logo = "pygmt_logo" - fig.savefig(fname=f"{fig_name_logo}.eps") - - return fig_name_logo, color_bg - - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - # End of subfunction - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # ............................................................................. + # Save + # ............................................................................. + fig_name_logo = "pygmt_logo" + fig.savefig(fname=f"{fig_name_logo}.eps") + + return fig_name_logo, color_bg + + +def pygmtlogo( # noqa: PLR0913 + self, + blackwhite=False, + darkmode=True, + hexshape=False, + wordmark=True, + orientation="horizontal", + position=None, # -> use position parameter of Figure.image + box=None, # -> use box parameter of Figure.image + projection=None, + region=None, + verbose=None, + panel=None, + transparency=None, +): + """ + Plot the PyGMT logo. + The design of the logo is kindly provided by `@sfrooti `_. + """ # ----------------------------------------------------------------------------- - # Replot and add to existing Figure instance + # Create logo file # ----------------------------------------------------------------------------- - fig_name_logo, color_bg = create_logo() + fig_name_logo, color_bg = create_logo( + blackwhite=blackwhite, + darkmode=darkmode, + hexshape=hexshape, + wordmark=wordmark, + orientation=orientation, + ) + # ----------------------------------------------------------------------------- + # Add box around logo + # ----------------------------------------------------------------------------- if box is None: box = f"+g{color_bg}" - # Use parameters of pygmt.Figure.image + # ----------------------------------------------------------------------------- + # Add to existing Figure instance + # ----------------------------------------------------------------------------- self.image( imagefile=f"{fig_name_logo}.eps", position=position, From 6ec39e7a353713da7ab6da293235983b731d39f6 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 20 Mar 2025 22:32:46 +0100 Subject: [PATCH 123/379] Adjust defaults --- pygmt/src/pygmtlogo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index a904bf5a8ef..a22e7d9a48e 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -10,7 +10,7 @@ def create_logo( # noqa: PLR0915 blackwhite=False, - darkmode=True, + darkmode=Flase, hexshape=False, wordmark=True, orientation="horizontal", @@ -244,7 +244,7 @@ def create_logo( # noqa: PLR0915 def pygmtlogo( # noqa: PLR0913 self, blackwhite=False, - darkmode=True, + darkmode=False, hexshape=False, wordmark=True, orientation="horizontal", @@ -275,8 +275,8 @@ def pygmtlogo( # noqa: PLR0913 # ----------------------------------------------------------------------------- # Add box around logo # ----------------------------------------------------------------------------- - if box is None: - box = f"+g{color_bg}" + # if box is None: + # box = f"+g{color_bg}" # ----------------------------------------------------------------------------- # Add to existing Figure instance From 787530d6671ba6fca25ee93b4e2aa52bc6289556 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 20 Mar 2025 22:33:03 +0100 Subject: [PATCH 124/379] Update gallery example --- examples/gallery/embellishments/pygmt_logo.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 13d3955b900..8ffa811fcf2 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -15,7 +15,7 @@ # %% fig = pygmt.Figure() -fig.pygmtlogo(darkmode=False) +fig.pygmtlogo(darkmode=True) fig.show() # %% @@ -23,11 +23,8 @@ fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gtan"]) -fig.logo() # GMT logo - -fig.pygmtlogo() -fig.pygmtlogo(darkmode=False, hexshape=True, position="jTL+o0.1c+w4c", box=False) -fig.pygmtlogo(darkmode=False, position="jTC+o0c/2c+w5c", box="+p1p,black") +fig.pygmtlogo(darkmode=False, position="jTR+o0.2c+w4c", box="+p1p,black") +fig.pygmtlogo(darkmode=False, hexshape=True, position="jTL+o0.2c+w4c", box=False) fig.pygmtlogo( blackwhite=True, From 7601e93e5b4a96295d84e49bad957c9f1e46cdbd Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 20 Mar 2025 22:36:38 +0100 Subject: [PATCH 125/379] Fix typo --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index a22e7d9a48e..e026851f2ed 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -10,7 +10,7 @@ def create_logo( # noqa: PLR0915 blackwhite=False, - darkmode=Flase, + darkmode=False, hexshape=False, wordmark=True, orientation="horizontal", From 1f1bfd913faa017205bc3291967b11e66da589ef Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 21 Mar 2025 10:58:39 +0100 Subject: [PATCH 126/379] Adjust gallery example --- examples/gallery/embellishments/pygmt_logo.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 8ffa811fcf2..7293d53d09f 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -15,7 +15,7 @@ # %% fig = pygmt.Figure() -fig.pygmtlogo(darkmode=True) +fig.pygmtlogo(darkmode=True, box="+gray20") fig.show() # %% @@ -23,24 +23,24 @@ fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gtan"]) -fig.pygmtlogo(darkmode=False, position="jTR+o0.2c+w4c", box="+p1p,black") -fig.pygmtlogo(darkmode=False, hexshape=True, position="jTL+o0.2c+w4c", box=False) +fig.pygmtlogo(position="jTL+o0.2c+w4c", box="+gwhite+p1p,gray") +fig.pygmtlogo(hexshape=True, position="jTR+o0.2c+w4c") fig.pygmtlogo( blackwhite=True, - darkmode=False, wordmark=False, position="jTL+o0.5c/2c+w1.5c", box=False, ) fig.pygmtlogo( blackwhite=True, + darkmode=True, hexshape=True, wordmark=False, position="jTR+o0.5c/2c+w1.5c", box=False, ) -fig.pygmtlogo(blackwhite=True, orientation="vertical", position="jMC+w2c") +fig.pygmtlogo(orientation="vertical", position="jMC+w2c") fig.show() From 1b51c05432c9d58641ae63d40ebf34fdec71b6b6 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 21 Mar 2025 11:08:49 +0100 Subject: [PATCH 127/379] Adjust docstring --- pygmt/src/pygmtlogo.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e026851f2ed..24fb64599be 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -23,17 +23,17 @@ def create_logo( # noqa: PLR0915 ---------- blackwhite : bool - Draw in black and white. ``False`` colors for Python (blue and yellow) - and GMT (red) are used [Default]. Use ``True`` for black and white. + Draw in black and white. Set to ``True`` for black and white [Default is + ``False`` and uses colors for Python (blue and yellow) and GMT (red)]. darkmode : bool - Use dark background. ``True`` leads to dark mode [Default] and ``False`` - to light mode. + Use dark mode. Set to``True`` for dark mode [Default is ``False`` for light + mode]. hexshape : bool - Use a hexagon shape. ``False`` leads to a circle shape [Default]. Use - ``True`` for a hexagon shape. + Use a hexagon shape. Set to ``True`` for a hexagon shape [Default is `False`` + and uses to a circle shape]. wordmark : bool - Add the wordmark "PyGMT". ``True`` adds the wordmark [Default] and ``False`` - to skipes it. + Add the wordmark "PyGMT". Set to `True`` to add the wordmark [Default]. For + ``False`` no wordmark is added. orientation : str Orientation of the wordmark. Use ``"horizontal"`` to place the wordmark at the right side [Default] or ``"vertical"`` to place it below the visual. From ebcf510a2c1d74623f6327cd08015978f77ad177 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 21 Mar 2025 12:06:40 +0100 Subject: [PATCH 128/379] Fix typo --- examples/gallery/embellishments/pygmt_logo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 7293d53d09f..1da9042cb64 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -15,7 +15,7 @@ # %% fig = pygmt.Figure() -fig.pygmtlogo(darkmode=True, box="+gray20") +fig.pygmtlogo(darkmode=True, box="+ggray20") fig.show() # %% From 9dbf09687768c21ef9ad8123f9d929b227d92542 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 26 Mar 2025 12:14:35 +0100 Subject: [PATCH 129/379] Update docstrings --- pygmt/src/pygmtlogo.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 24fb64599be..3d2ff3b56e0 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -31,12 +31,11 @@ def create_logo( # noqa: PLR0915 hexshape : bool Use a hexagon shape. Set to ``True`` for a hexagon shape [Default is `False`` and uses to a circle shape]. - wordmark : bool - Add the wordmark "PyGMT". Set to `True`` to add the wordmark [Default]. For - ``False`` no wordmark is added. - orientation : str - Orientation of the wordmark. Use ``"horizontal"`` to place the wordmark at - the right side [Default] or ``"vertical"`` to place it below the visual. + wordmark : bool, str + Add the wordmark "PyGMT" and adjust its orientation relative to the visual. + Set to `True`` or ``"horizontal"``, to add the wordmark at the right side of + the visual [Default]. Use ``"vertical"`` to place the wordmark below the + visual and ``False`` to add no wordmark. """ # ----------------------------------------------------------------------------- From b07fe8c9cdb6d679dc7fd668c0149eaff7b51c5e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 26 Mar 2025 12:25:13 +0100 Subject: [PATCH 130/379] Include 'orientation' parameter into 'wordmark' parameter --- pygmt/src/pygmtlogo.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 3d2ff3b56e0..36a60347d29 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -13,7 +13,6 @@ def create_logo( # noqa: PLR0915 darkmode=False, hexshape=False, wordmark=True, - orientation="horizontal", ): """ Creat the PyGMT logo. @@ -95,7 +94,7 @@ def create_logo( # noqa: PLR0915 # Define wordmark # ----------------------------------------------------------------------------- font = "AvantGarde-Book" - match orientation: + match wordmark: case "vertical": args_text_wm = { "x": 0, @@ -103,7 +102,7 @@ def create_logo( # noqa: PLR0915 "justify": "CT", "font": f"2.5c,{font}", } - case "horizontal": + case True | "horizontal": args_text_wm = { "x": 6, "y": 0, @@ -246,7 +245,6 @@ def pygmtlogo( # noqa: PLR0913 darkmode=False, hexshape=False, wordmark=True, - orientation="horizontal", position=None, # -> use position parameter of Figure.image box=None, # -> use box parameter of Figure.image projection=None, @@ -268,7 +266,6 @@ def pygmtlogo( # noqa: PLR0913 darkmode=darkmode, hexshape=hexshape, wordmark=wordmark, - orientation=orientation, ) # ----------------------------------------------------------------------------- From ea9e9e0c8d535fa7582f3ebf7333b68b96a6fee1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 26 Mar 2025 12:25:41 +0100 Subject: [PATCH 131/379] Update gallery example --- examples/gallery/embellishments/pygmt_logo.py | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 1da9042cb64..c0831603f12 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -40,8 +40,50 @@ position="jTR+o0.5c/2c+w1.5c", box=False, ) -fig.pygmtlogo(orientation="vertical", position="jMC+w2c") +fig.pygmtlogo(wordmark="vertical", position="jMC+w2c") fig.show() +# %% +# All combinations + +i_plot = 0 + +fig = pygmt.Figure() + +for blackwhite in [False, True]: + for darkmode in [False, True]: + for hexshape in [False, True]: + for wordmark in [True, False, "horizontal", "vertical"]: + for box in [False, True]: + if not box: + box_used = False + elif box: + if not darkmode: + box_used = "+gwhite" + elif darkmode: + box_used = "+ggray20" + # fig = pygmt.Figure() + fig.basemap(region=[-1, 1, -1, 1], projection="X2c", frame="+gcyan") + # fig.image("@needle.png", position="jMC+w1.8c", box=box_used) + fig.pygmtlogo( + blackwhite=blackwhite, + darkmode=darkmode, + hexshape=hexshape, + wordmark=wordmark, + position="jMC+w1.8c", + box=box, + ) + + fig.shift_origin(xshift="+w+0.5c") + n_hor = 8 + if i_plot in range(n_hor - 1, 100, n_hor): + fig.shift_origin( + xshift=f"-{(n_hor * 2 + n_hor * 0.5)}c", + yshift="-h-0.5c", + ) # n_hor*width + n_hor*xshift + + i_plot = i_plot + 1 +fig.show() + # sphinx_gallery_thumbnail_number = 3 From 4bb45af9c8f90debf29539f57333834b2186c75c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 26 Mar 2025 12:30:15 +0100 Subject: [PATCH 132/379] Do not plot invisible basemap at the beginning Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 36a60347d29..4cd104e4de8 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -114,12 +114,6 @@ def create_logo( # noqa: PLR0915 # Start plotting # ----------------------------------------------------------------------------- fig = pygmt.Figure() - pygmt.config(MAP_FRAME_PEN=no_line) - fig.basemap( - region=region, - projection=f"X{size * 2}c", - frame=no_fill, - ) # ............................................................................. # blue circle / hexagon for Earth @@ -127,6 +121,8 @@ def create_logo( # noqa: PLR0915 fig.plot( x=0, y=0, + region=region, + projection=f"X{size * 2}c", style=f"{symbol}{diameter}c", pen=f"15p,{color_blue}", fill=color_bg, From 33517d6c62bec630a2f389fdf1f740e6f1cab300 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 26 Mar 2025 12:40:50 +0100 Subject: [PATCH 133/379] Remove un-needed variable --- pygmt/src/pygmtlogo.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4cd104e4de8..46498d47769 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -46,9 +46,6 @@ def create_logo( # noqa: PLR0915 xy_yellow_1 = 2.65 xy_yellow_2 = 1.3 - no_line = "cyan@100" - no_fill = f"+g{no_line}" - # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True # Do NOT rotated initial basemap From f7e5cd69349efddca6aef699f6c68e026c3c6465 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 26 Mar 2025 13:14:42 +0100 Subject: [PATCH 134/379] Fix variable name after renaming for coding style --- examples/gallery/embellishments/pygmt_logo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index c0831603f12..78ca0ab7762 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -64,15 +64,15 @@ elif darkmode: box_used = "+ggray20" # fig = pygmt.Figure() - fig.basemap(region=[-1, 1, -1, 1], projection="X2c", frame="+gcyan") - # fig.image("@needle.png", position="jMC+w1.8c", box=box_used) + fig.basemap(region=[-1, 1, -1, 1], projection="X2c", frame="+gtan") + # fig.image("@needle.png", position="jMC+w1.5c", box=box_used) fig.pygmtlogo( blackwhite=blackwhite, darkmode=darkmode, hexshape=hexshape, wordmark=wordmark, position="jMC+w1.8c", - box=box, + box=box_used, ) fig.shift_origin(xshift="+w+0.5c") From 11b9a49d88cde0e998dc173332351fc0d8451d81 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 26 Mar 2025 13:50:37 +0100 Subject: [PATCH 135/379] Remove un-needed comment --- examples/gallery/embellishments/pygmt_logo.py | 8 ++++---- pygmt/src/pygmtlogo.py | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 78ca0ab7762..e85cf57d2b7 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -64,14 +64,14 @@ elif darkmode: box_used = "+ggray20" # fig = pygmt.Figure() - fig.basemap(region=[-1, 1, -1, 1], projection="X2c", frame="+gtan") - # fig.image("@needle.png", position="jMC+w1.5c", box=box_used) + fig.basemap(region=[-1, 1, -1, 1], projection="X2.5c", frame="+gtan") + # fig.image("@needle.png", position="jMC+w2c", box=box_used) fig.pygmtlogo( blackwhite=blackwhite, darkmode=darkmode, hexshape=hexshape, wordmark=wordmark, - position="jMC+w1.8c", + position="jMC+w2c", box=box_used, ) @@ -79,7 +79,7 @@ n_hor = 8 if i_plot in range(n_hor - 1, 100, n_hor): fig.shift_origin( - xshift=f"-{(n_hor * 2 + n_hor * 0.5)}c", + xshift=f"-{(n_hor * 2.5 + n_hor * 0.5)}c", yshift="-h-0.5c", ) # n_hor*width + n_hor*xshift diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 46498d47769..95be06be324 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -48,7 +48,6 @@ def create_logo( # noqa: PLR0915 # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True - # Do NOT rotated initial basemap angle_rot = 30 # degrees perspective = f"{angle_rot}+w0/0" From 95aee4fda7cffa61c80abd688a2f6f6860a83b50 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 26 Mar 2025 13:51:52 +0100 Subject: [PATCH 136/379] Remove un-needed code block --- pygmt/src/pygmtlogo.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 95be06be324..6889ede57dc 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -260,12 +260,6 @@ def pygmtlogo( # noqa: PLR0913 wordmark=wordmark, ) - # ----------------------------------------------------------------------------- - # Add box around logo - # ----------------------------------------------------------------------------- - # if box is None: - # box = f"+g{color_bg}" - # ----------------------------------------------------------------------------- # Add to existing Figure instance # ----------------------------------------------------------------------------- From d4c17aeb4242fa8b6221f6a0b4c07434f8e03e09 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 26 Mar 2025 13:54:02 +0100 Subject: [PATCH 137/379] Fix code style --- examples/gallery/embellishments/pygmt_logo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index e85cf57d2b7..8838ac57294 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -64,7 +64,9 @@ elif darkmode: box_used = "+ggray20" # fig = pygmt.Figure() - fig.basemap(region=[-1, 1, -1, 1], projection="X2.5c", frame="+gtan") + fig.basemap( + region=[-1, 1, -1, 1], projection="X2.5c", frame="+gtan" + ) # fig.image("@needle.png", position="jMC+w2c", box=box_used) fig.pygmtlogo( blackwhite=blackwhite, From 3cdd4f3a83b0371565f853a4020aedf39b0c8b79 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 26 Mar 2025 17:50:45 +0100 Subject: [PATCH 138/379] Update intro text of gallery example --- examples/gallery/embellishments/pygmt_logo.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 8838ac57294..15d1394c137 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -1,9 +1,13 @@ """ PyGMT logo ========== -The PyGMT logo coded in Python using PyGMT. The design of the logo is kindly provided -by `@sfrooti `_. The logo consists of a visual and the -wordmark "PyGMT". +Beside the GMT logo, there is a separate PyGMT logo which can be plotted and added +to a figure using :method:`pygmt.Figure.pygmtlogo`. The design of the logo itself +is kindly provided by `@sfrooti `_ and consists of a +visual and the wordmark "PyGMT". +The logo is available in circle and hexagon shape. It can be plotted using colors +of Python (blue and yellow) and GMT (red) or in black and white as well as in light +or dark mode. The wordmark can be added at the right side or bottom of the visual. """ import pygmt @@ -40,7 +44,7 @@ position="jTR+o0.5c/2c+w1.5c", box=False, ) -fig.pygmtlogo(wordmark="vertical", position="jMC+w2c") +fig.pygmtlogo(wordmark="vertical", position="jMC+w2c", box="+gwhite") fig.show() @@ -54,7 +58,7 @@ for blackwhite in [False, True]: for darkmode in [False, True]: for hexshape in [False, True]: - for wordmark in [True, False, "horizontal", "vertical"]: + for wordmark in [False, True, "horizontal", "vertical"]: for box in [False, True]: if not box: box_used = False From 38e15f74937d22de591a92b708a0e48e382ae4dc Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 26 Mar 2025 17:54:40 +0100 Subject: [PATCH 139/379] Update docs --- pygmt/src/pygmtlogo.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6889ede57dc..db76b1dea9b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -1,6 +1,7 @@ """ pygmtlogo - Create and plot the PyGMT logo. -The design of the logo is kindly provided by `@sfrooti `_. +The design of the logo is kindly provided by `@sfrooti `_ +and consists of a visual and the wordmark "PyGMT". """ from pathlib import Path @@ -15,8 +16,9 @@ def create_logo( # noqa: PLR0915 wordmark=True, ): """ - Creat the PyGMT logo. - The design of the logo is kindly provided by `@sfrooti `_. + Create the PyGMT logo using PyGMT. + The design of the logo is kindly provided by `@sfrooti `_ + and consists of a visual and the wordmark "PyGMT". Parameters ---------- @@ -247,7 +249,6 @@ def pygmtlogo( # noqa: PLR0913 ): """ Plot the PyGMT logo. - The design of the logo is kindly provided by `@sfrooti `_. """ # ----------------------------------------------------------------------------- From 2f6decbd7089db332c1d387ecd94fe82b25e8a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 27 Mar 2025 16:11:27 +0100 Subject: [PATCH 140/379] Use fixed angle for rotation -> remove variable Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index db76b1dea9b..7ecfe483215 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -50,8 +50,7 @@ def create_logo( # noqa: PLR0915 # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True - angle_rot = 30 # degrees - perspective = f"{angle_rot}+w0/0" + perspective = f"30+w0/0" # Rotation by 30 degrees # ----------------------------------------------------------------------------- # Define colors From eaa6e129f67871a75016b78d0dfe65addfb8092c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 27 Mar 2025 16:18:28 +0100 Subject: [PATCH 141/379] Shorten variable names Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 7ecfe483215..60a6628614d 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -172,15 +172,14 @@ def create_logo( # noqa: PLR0915 # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) # lines with small distance to horizontal line of letter G - args_m = {"pen": f"10p,{color_red}", "perspective": True} lines_m = [ ([0.33, 0.90], [1.527, 1.00]), # diagonal left ([0.90, 1.43], [1.00, 1.527]), # diagonal right ([0.285, 0.285], [0.30, 1.65]), # vertical left ([1.47, 1.47], [0.30, 1.65]), # vertical right ] - for x_coords, y_coords in lines_m: - fig.plot(x=x_coords, y=y_coords, **args_m) + for x, y in lines_m: + fig.plot(x=x, y=y, pen=f"10p,{color_red}", perspective=True) # middle corner fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) From 85d09d2c4625b91f79c955713aef9a5e57085cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 27 Mar 2025 16:19:59 +0100 Subject: [PATCH 142/379] Shorten variable names for compass lines Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 60a6628614d..02352269d9b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -45,8 +45,7 @@ def create_logo( # noqa: PLR0915 size = 4 region = [-size, size] * 2 - xy_yellow_1 = 2.65 - xy_yellow_2 = 1.3 + r1, r2 = size * 0.625, size * 0.325 # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True @@ -135,13 +134,13 @@ def create_logo( # noqa: PLR0915 fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) # diagonal yellow lines lines_diagonal = [ - ([-xy_yellow_1, -xy_yellow_2], [xy_yellow_1, xy_yellow_2]), # upper left - ([xy_yellow_2, xy_yellow_1], [-xy_yellow_2, -xy_yellow_1]), # lower right - ([-xy_yellow_1, -xy_yellow_2], [-xy_yellow_1, -xy_yellow_2]), # lower left - ([xy_yellow_2, xy_yellow_1], [xy_yellow_2, xy_yellow_1]), # upper right + ([-r1, -r2], [r1, r2]), # upper left + ([-r1, -r2], [-r1, -r2]), # lower left + ([r1, r2], [r1, r2]), # lower left + ([r1, r2], [-r1, -r2]), # lower right ] - for x_coords, y_coords in lines_diagonal: - fig.plot(x=x_coords, y=y_coords, **args_yellow) + for x, y in lines_diagonal: + fig.plot(x=x, y=y, **args_yellow) # ............................................................................. # letter G From 81162957e8871bc9a861a6474b797c3770ea2195 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 27 Mar 2025 16:34:54 +0100 Subject: [PATCH 143/379] Remove un-needed string f --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 02352269d9b..71649b0aff5 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -49,7 +49,7 @@ def create_logo( # noqa: PLR0915 # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True - perspective = f"30+w0/0" # Rotation by 30 degrees + perspective = "30+w0/0" # Rotation by 30 degrees # ----------------------------------------------------------------------------- # Define colors From a50ebfd2c66195ce8cbe60e7f509cc99f0712b4b Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 27 Mar 2025 19:26:00 +0100 Subject: [PATCH 144/379] Update parameter names --- pygmt/src/pygmtlogo.py | 66 +++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 71649b0aff5..6293fed4987 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -10,9 +10,9 @@ def create_logo( # noqa: PLR0915 - blackwhite=False, - darkmode=False, - hexshape=False, + color=True, + theme="light", + shape="circle", wordmark=True, ): """ @@ -23,15 +23,15 @@ def create_logo( # noqa: PLR0915 Parameters ---------- - blackwhite : bool - Draw in black and white. Set to ``True`` for black and white [Default is - ``False`` and uses colors for Python (blue and yellow) and GMT (red)]. - darkmode : bool - Use dark mode. Set to``True`` for dark mode [Default is ``False`` for light - mode]. - hexshape : bool - Use a hexagon shape. Set to ``True`` for a hexagon shape [Default is `False`` - and uses to a circle shape]. + color : bool + Set to ``True`` to use colors refering to Python (blue and yellow) and GMT (red) + [Default]. For ``False``, the logo is drawn in black and white. + theme : str + Use ``"light"`` for light mode (i.e., white background) [Default] and ``"dark"`` + for dark mode (i.e., gray20 background). + shape : str + Shape of the visual. Use ``"circle"`` for a circle shape [Default] or + ``"hexagon"`` for a hexagon shape. wordmark : bool, str Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set to `True`` or ``"horizontal"``, to add the wordmark at the right side of @@ -54,26 +54,26 @@ def create_logo( # noqa: PLR0915 # ----------------------------------------------------------------------------- # Define colors # ----------------------------------------------------------------------------- - color_dark = "gray20" color_light = "white" + color_dark = "gray20" # visual color_blue = "48/105/152" # Python blue color_yellow = "255/212/59" # Python yellow color_red = "238/86/52" # GMT red - if blackwhite: - color_blue = color_yellow = color_red = color_light - if not darkmode: - color_blue = color_yellow = color_red = color_dark + if not color: + color_blue = color_yellow = color_red = color_dark + if theme == "dark": + color_blue = color_yellow = color_red = color_light # background and wordmark - color_bg = color_dark - color_py = color_yellow - color_gmt = color_light - if not darkmode: - color_bg = color_light - color_py = color_blue - color_gmt = color_dark + color_bg = color_light + color_py = color_blue + color_gmt = color_dark + if theme == "dark": + color_bg = color_dark + color_py = color_yellow + color_gmt = color_light # ----------------------------------------------------------------------------- # Define shape @@ -81,7 +81,7 @@ def create_logo( # noqa: PLR0915 symbol = "c" # circle diameter = 7.5 diameter_add = 0.5 - if hexshape: + if shape == "hexagon": symbol = "h" # hexagon diameter = 8.6 diameter_add = 0.6 @@ -203,8 +203,8 @@ def create_logo( # noqa: PLR0915 # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) - # margin around shape for blackwhite=True in darkmode=True - if blackwhite and darkmode: + # margin around shape + if not color and theme == "dark": fig.plot( x=0, y=0, @@ -232,9 +232,9 @@ def create_logo( # noqa: PLR0915 def pygmtlogo( # noqa: PLR0913 self, - blackwhite=False, - darkmode=False, - hexshape=False, + color=True, + theme="light", + shape="circle", wordmark=True, position=None, # -> use position parameter of Figure.image box=None, # -> use box parameter of Figure.image @@ -252,9 +252,9 @@ def pygmtlogo( # noqa: PLR0913 # Create logo file # ----------------------------------------------------------------------------- fig_name_logo, color_bg = create_logo( - blackwhite=blackwhite, - darkmode=darkmode, - hexshape=hexshape, + color=color, + theme=theme, + shape=shape, wordmark=wordmark, ) From f0f7fbd4d09e64acc8a11439bf7767b53855df45 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 27 Mar 2025 19:26:16 +0100 Subject: [PATCH 145/379] Update gallery example --- examples/gallery/embellishments/pygmt_logo.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 15d1394c137..712d1826b54 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -19,7 +19,7 @@ # %% fig = pygmt.Figure() -fig.pygmtlogo(darkmode=True, box="+ggray20") +fig.pygmtlogo(theme="dark", box="+ggray20") fig.show() # %% @@ -28,18 +28,18 @@ fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gtan"]) fig.pygmtlogo(position="jTL+o0.2c+w4c", box="+gwhite+p1p,gray") -fig.pygmtlogo(hexshape=True, position="jTR+o0.2c+w4c") +fig.pygmtlogo(shape="hexagon", position="jTR+o0.2c+w4c") fig.pygmtlogo( - blackwhite=True, + color=False, wordmark=False, position="jTL+o0.5c/2c+w1.5c", box=False, ) fig.pygmtlogo( - blackwhite=True, - darkmode=True, - hexshape=True, + color=False, + theme="dark", + shape="hexagon", wordmark=False, position="jTR+o0.5c/2c+w1.5c", box=False, @@ -55,17 +55,17 @@ fig = pygmt.Figure() -for blackwhite in [False, True]: - for darkmode in [False, True]: - for hexshape in [False, True]: +for color in [True, False]: + for theme in ["light", "dark"]: + for shape in ["circle", "hexagon"]: for wordmark in [False, True, "horizontal", "vertical"]: for box in [False, True]: if not box: box_used = False elif box: - if not darkmode: + if theme == "light": box_used = "+gwhite" - elif darkmode: + elif theme == "dark": box_used = "+ggray20" # fig = pygmt.Figure() fig.basemap( @@ -73,9 +73,9 @@ ) # fig.image("@needle.png", position="jMC+w2c", box=box_used) fig.pygmtlogo( - blackwhite=blackwhite, - darkmode=darkmode, - hexshape=hexshape, + color=color, + theme=theme, + shape=shape, wordmark=wordmark, position="jMC+w2c", box=box_used, From 6d360d3f361722087214125d9d06e2dc205e3879 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 27 Mar 2025 21:30:39 +0100 Subject: [PATCH 146/379] Improve docs --- pygmt/src/pygmtlogo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6293fed4987..243ddfe2fb3 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -28,7 +28,7 @@ def create_logo( # noqa: PLR0915 [Default]. For ``False``, the logo is drawn in black and white. theme : str Use ``"light"`` for light mode (i.e., white background) [Default] and ``"dark"`` - for dark mode (i.e., gray20 background). + for dark mode (i.e., darkgray [gray20] background). shape : str Shape of the visual. Use ``"circle"`` for a circle shape [Default] or ``"hexagon"`` for a hexagon shape. @@ -45,6 +45,7 @@ def create_logo( # noqa: PLR0915 size = 4 region = [-size, size] * 2 + # Outer and inner radii of compass lines r1, r2 = size * 0.625, size * 0.325 # Rotation around z (vertical) axis placed in the center From b74eb73ee1518a2eeb69664faa4cb3003c292466 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 27 Mar 2025 21:35:44 +0100 Subject: [PATCH 147/379] Fit code in one line --- pygmt/src/pygmtlogo.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 243ddfe2fb3..1490c41541c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -9,12 +9,7 @@ import pygmt -def create_logo( # noqa: PLR0915 - color=True, - theme="light", - shape="circle", - wordmark=True, -): +def create_logo(color=True, theme="light", shape="circle", wordmark=True): # noqa: PLR0915 """ Create the PyGMT logo using PyGMT. The design of the logo is kindly provided by `@sfrooti `_ @@ -253,10 +248,7 @@ def pygmtlogo( # noqa: PLR0913 # Create logo file # ----------------------------------------------------------------------------- fig_name_logo, color_bg = create_logo( - color=color, - theme=theme, - shape=shape, - wordmark=wordmark, + color=color, theme=theme, shape=shape, wordmark=wordmark ) # ----------------------------------------------------------------------------- From 0cec69719cfa45a95302882481123620b5f1612f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 27 Mar 2025 21:35:54 +0100 Subject: [PATCH 148/379] Fit code in one line --- examples/gallery/embellishments/pygmt_logo.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 712d1826b54..43d5d487c31 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -30,12 +30,7 @@ fig.pygmtlogo(position="jTL+o0.2c+w4c", box="+gwhite+p1p,gray") fig.pygmtlogo(shape="hexagon", position="jTR+o0.2c+w4c") -fig.pygmtlogo( - color=False, - wordmark=False, - position="jTL+o0.5c/2c+w1.5c", - box=False, -) +fig.pygmtlogo(color=False, wordmark=False, position="jTL+o0.5c/2c+w1.5c", box=False) fig.pygmtlogo( color=False, theme="dark", From eaed88a215764293f329b42de6225a40e7533f6d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 27 Mar 2025 21:38:47 +0100 Subject: [PATCH 149/379] Fix comments --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 1490c41541c..114670607d6 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -132,7 +132,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no lines_diagonal = [ ([-r1, -r2], [r1, r2]), # upper left ([-r1, -r2], [-r1, -r2]), # lower left - ([r1, r2], [r1, r2]), # lower left + ([r1, r2], [r1, r2]), # upper right ([r1, r2], [-r1, -r2]), # lower right ] for x, y in lines_diagonal: From 3b8f3d75c3c215f1ef01c64c432e3b48315bc9e3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 27 Mar 2025 21:42:12 +0100 Subject: [PATCH 150/379] Improve comment --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 114670607d6..bcc06b9abe6 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -199,7 +199,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) - # margin around shape + # outline around shape for black and white with dark theme (i.e., white shape) if not color and theme == "dark": fig.plot( x=0, From 28e79ae39b76363d4ae2d62cf78f79dd7fc392d0 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 27 Mar 2025 21:44:42 +0100 Subject: [PATCH 151/379] Fix typo --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index bcc06b9abe6..fb7ec62cc0f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -19,7 +19,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ---------- color : bool - Set to ``True`` to use colors refering to Python (blue and yellow) and GMT (red) + Set to ``True`` to use colors referring to Python (blue and yellow) and GMT (red) [Default]. For ``False``, the logo is drawn in black and white. theme : str Use ``"light"`` for light mode (i.e., white background) [Default] and ``"dark"`` From b766c1b71c21e69c76845b0c29a84bcad489dc11 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 27 Mar 2025 21:52:20 +0100 Subject: [PATCH 152/379] Fix length --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index fb7ec62cc0f..828d0085906 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -19,8 +19,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ---------- color : bool - Set to ``True`` to use colors referring to Python (blue and yellow) and GMT (red) - [Default]. For ``False``, the logo is drawn in black and white. + Set to ``True`` to use colors referring to Python (blue and yellow) and GMT + (red) [Default]. For ``False``, the logo is drawn in black and white. theme : str Use ``"light"`` for light mode (i.e., white background) [Default] and ``"dark"`` for dark mode (i.e., darkgray [gray20] background). From 62a70b8de400ce4278bebcf1bfe70d2a2b7e917e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 28 Mar 2025 13:38:38 +0100 Subject: [PATCH 153/379] Remove un-used 'no_clip' parameter Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 828d0085906..7095473e22d 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -125,18 +125,15 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # ............................................................................. # yellow lines for compass # ............................................................................. - args_yellow = {"pen": f"5p,{color_yellow}", "perspective": True} - # horizontal yellow line - fig.plot(x=[-4, 4], y=[0, 0], no_clip=True, **args_yellow) - # diagonal yellow lines - lines_diagonal = [ + lines = [ + ([-size, size], [0, 0]), # horizontal line ([-r1, -r2], [r1, r2]), # upper left ([-r1, -r2], [-r1, -r2]), # lower left ([r1, r2], [r1, r2]), # upper right ([r1, r2], [-r1, -r2]), # lower right ] - for x, y in lines_diagonal: - fig.plot(x=x, y=y, **args_yellow) + for x, y in lines: + fig.plot(x=x, y=y, pen=f"5p,{color_yellow}", perspective=True) # ............................................................................. # letter G From d01531f0e182273fbc93319e9f879cb127e5618f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 28 Mar 2025 13:44:22 +0100 Subject: [PATCH 154/379] Remove un-needed 'no_clip' parameter --- pygmt/src/pygmtlogo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 7095473e22d..91676d835c3 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -118,7 +118,6 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no style=f"{symbol}{diameter}c", pen=f"15p,{color_blue}", fill=color_bg, - no_clip=True, perspective=perspective, ) From 5086e115c34b92277907ab859a73c8e44a001a3e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 28 Mar 2025 13:45:05 +0100 Subject: [PATCH 155/379] Adjust variable name --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 91676d835c3..61fee649d28 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -124,14 +124,14 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # ............................................................................. # yellow lines for compass # ............................................................................. - lines = [ + lines_yellow = [ ([-size, size], [0, 0]), # horizontal line ([-r1, -r2], [r1, r2]), # upper left ([-r1, -r2], [-r1, -r2]), # lower left ([r1, r2], [r1, r2]), # upper right ([r1, r2], [-r1, -r2]), # lower right ] - for x, y in lines: + for x, y in lines_yellow: fig.plot(x=x, y=y, pen=f"5p,{color_yellow}", perspective=True) # ............................................................................. From b969a8255cdf647cc02b8a1d4d8cb094474234dc Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 28 Mar 2025 14:53:45 +0100 Subject: [PATCH 156/379] Remove un-needed 'no_clip' parameter --- pygmt/src/pygmtlogo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 61fee649d28..ccfc1febf74 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -202,7 +202,6 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no y=0, style=f"{symbol}{diameter + diameter_add}c", pen=f"1p,{color_dark}", - no_clip=True, perspective=True, ) From d4effc41fa9b71842d5d348ac146910398c120aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 29 Mar 2025 13:56:51 +0100 Subject: [PATCH 157/379] Add 'no_clip' parameter back for hexagon shape --- pygmt/src/pygmtlogo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index ccfc1febf74..45a4932700e 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -119,6 +119,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no pen=f"15p,{color_blue}", fill=color_bg, perspective=perspective, + no_clip=True, # needed for corners of hexagon shape ) # ............................................................................. From c78b2f37a23d9a8702d83eb1bfd715c2751ab016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 29 Mar 2025 14:40:25 +0100 Subject: [PATCH 158/379] Add 'no_clip' parameter back for hexagon shape --- pygmt/src/pygmtlogo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 45a4932700e..a306c4d4ec6 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -204,6 +204,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no style=f"{symbol}{diameter + diameter_add}c", pen=f"1p,{color_dark}", perspective=True, + no_clip=True, ) # ............................................................................. From 08670855d532215b1c4cc0614594739d09583898 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 15:11:35 +0100 Subject: [PATCH 159/379] TEST Add invisible basemap back to also have a square for hexagon shape --- pygmt/src/pygmtlogo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index a306c4d4ec6..add4985b7df 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -38,7 +38,6 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Helpful definitions # ----------------------------------------------------------------------------- size = 4 - region = [-size, size] * 2 # Outer and inner radii of compass lines r1, r2 = size * 0.625, size * 0.325 @@ -106,6 +105,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Start plotting # ----------------------------------------------------------------------------- fig = pygmt.Figure() + fig.basemap(region=[-size, size] * 2, projection=f"X{size * 2}c", frame="+gcyn@100") # ............................................................................. # blue circle / hexagon for Earth @@ -113,8 +113,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig.plot( x=0, y=0, - region=region, - projection=f"X{size * 2}c", + # region=[-size, size] * 2, + # projection=f"X{size * 2}c", style=f"{symbol}{diameter}c", pen=f"15p,{color_blue}", fill=color_bg, From 77636b6e1fd66703d1c52c4b579852843ce756df Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 15:11:57 +0100 Subject: [PATCH 160/379] Adjust size of basemap in all combination test plot --- examples/gallery/embellishments/pygmt_logo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 43d5d487c31..dfc03d96539 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -64,7 +64,7 @@ box_used = "+ggray20" # fig = pygmt.Figure() fig.basemap( - region=[-1, 1, -1, 1], projection="X2.5c", frame="+gtan" + region=[-1, 1, -1, 1], projection="X2.5c/3.5c", frame="+gtan" ) # fig.image("@needle.png", position="jMC+w2c", box=box_used) fig.pygmtlogo( From 229046c3d01585f07cf95e4159867822ca0c782a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 15:35:06 +0100 Subject: [PATCH 161/379] Fix syntax and use maximum line lenght --- examples/gallery/embellishments/pygmt_logo.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index dfc03d96539..ffd08427f9b 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -2,12 +2,12 @@ PyGMT logo ========== Beside the GMT logo, there is a separate PyGMT logo which can be plotted and added -to a figure using :method:`pygmt.Figure.pygmtlogo`. The design of the logo itself -is kindly provided by `@sfrooti `_ and consists of a -visual and the wordmark "PyGMT". -The logo is available in circle and hexagon shape. It can be plotted using colors -of Python (blue and yellow) and GMT (red) or in black and white as well as in light -or dark mode. The wordmark can be added at the right side or bottom of the visual. +to a figure using :meth:`pygmt.Figure.pygmtlogo`. The design of the logo itself is +kindly provided by `@sfrooti `_ and consists of a visual +and the wordmark "PyGMT". +The logo is available in circle and hexagon shape. It can be plotted using colors of +Python (blue and yellow) and GMT (red) or in black and white as well as in light or +dark mode. The wordmark can be added at the right side or bottom of the visual. """ import pygmt From 9b7d1e90332d8debcaacc865e5a742ff254cd99c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 18:20:32 +0100 Subject: [PATCH 162/379] Fix highlighting --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index add4985b7df..82fa01bbf07 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -29,7 +29,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ``"hexagon"`` for a hexagon shape. wordmark : bool, str Add the wordmark "PyGMT" and adjust its orientation relative to the visual. - Set to `True`` or ``"horizontal"``, to add the wordmark at the right side of + Set to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and ``False`` to add no wordmark. """ From 54f8880e284c71a32c1dbfd474c5ca55a4ee60c9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 18:50:14 +0100 Subject: [PATCH 163/379] Fix typo in code --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 82fa01bbf07..67796222cef 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -105,7 +105,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Start plotting # ----------------------------------------------------------------------------- fig = pygmt.Figure() - fig.basemap(region=[-size, size] * 2, projection=f"X{size * 2}c", frame="+gcyn@100") + fig.basemap(region=[-size, size] * 2, projection=f"X{size * 2}c", frame="+gcyan@100") # ............................................................................. # blue circle / hexagon for Earth From 5c8e12fe19b56674433569199a27819e1b513e57 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 18:53:08 +0100 Subject: [PATCH 164/379] Fix line length --- pygmt/src/pygmtlogo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 67796222cef..b39ca5f5158 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -105,7 +105,9 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Start plotting # ----------------------------------------------------------------------------- fig = pygmt.Figure() - fig.basemap(region=[-size, size] * 2, projection=f"X{size * 2}c", frame="+gcyan@100") + fig.basemap( + region=[-size, size] * 2, projection=f"X{size * 2}c", frame="+gcyan@100" + ) # ............................................................................. # blue circle / hexagon for Earth From 5fd657f1cc6641f060144b7360fd11bba68143b1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 19:16:53 +0100 Subject: [PATCH 165/379] Remove invisble basemap --- pygmt/src/pygmtlogo.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index b39ca5f5158..6f35e8c6461 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -105,9 +105,6 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Start plotting # ----------------------------------------------------------------------------- fig = pygmt.Figure() - fig.basemap( - region=[-size, size] * 2, projection=f"X{size * 2}c", frame="+gcyan@100" - ) # ............................................................................. # blue circle / hexagon for Earth @@ -115,8 +112,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig.plot( x=0, y=0, - # region=[-size, size] * 2, - # projection=f"X{size * 2}c", + region=[-size, size] * 2, + projection=f"X{size * 2}c", style=f"{symbol}{diameter}c", pen=f"15p,{color_blue}", fill=color_bg, From 1ed44b48ab0c9ff225504c1a914321f150b236bd Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 21:25:33 +0100 Subject: [PATCH 166/379] Add code for all versions Co-authored-by: Dongdong Tian --- examples/gallery/embellishments/pygmt_logo.py | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index ffd08427f9b..d5c037130ff 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -87,4 +87,59 @@ i_plot = i_plot + 1 fig.show() + +# ## +# All versions +# modified from +# https://github.com/GenericMappingTools/pygmt/pull/3849#issuecomment-2753372170 +# by @seisman + +fig = pygmt.Figure() + +# Logo without workmark. +fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame="a1f1g1") +for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: + for color, shape in [(True, "circle"), (False, "hexagon")]: + fig.pygmtlogo( + color=color, + theme=theme, + shape=shape, + wordmark=False, + position=f"g{x}/{y}+jTL+w2c", + ) + y += 3 # noqa: PLW2901 + +fig.shift_origin(xshift=8) + +# Logo with vertical wordmark. +fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame="a1f1g1") +for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: + for color, shape in [(True, "circle"), (False, "hexagon")]: + fig.pygmtlogo( + color=color, + theme=theme, + shape=shape, + wordmark="vertical", + position=f"g{x}/{y}+jTL+w2c", + ) + y += 3 # noqa: PLW2901 + +fig.shift_origin(xshift=8) + +# Logo with horizontal wordmark. +fig.basemap(region=[0, 20, 0, 13], projection="x1c", frame="a1f1g1") +for x, y, theme in [(1, 3, "light"), (11, 3, "dark")]: + for color, shape in [(True, "circle"), (False, "hexagon")]: + fig.pygmtlogo( + color=color, + theme=theme, + shape=shape, + wordmark="horizontal", + position=f"g{x}/{y}+jTL+w0/2c", + ) + y += 3 # noqa: PLW2901 + +fig.show(width=1000) + + # sphinx_gallery_thumbnail_number = 3 From 92ccf9721a3179f9305897235515f62696ef3566 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 21:39:11 +0100 Subject: [PATCH 167/379] Fix seperator --- examples/gallery/embellishments/pygmt_logo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index d5c037130ff..55421939365 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -88,7 +88,7 @@ fig.show() -# ## +# %% # All versions # modified from # https://github.com/GenericMappingTools/pygmt/pull/3849#issuecomment-2753372170 From 3296b11f8f7745b1cbd603086469aa3d7f89f7bd Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 21:41:33 +0100 Subject: [PATCH 168/379] Add more combinations --- examples/gallery/embellishments/pygmt_logo.py | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 55421939365..beb95217c95 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -99,7 +99,12 @@ # Logo without workmark. fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame="a1f1g1") for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: - for color, shape in [(True, "circle"), (False, "hexagon")]: + for color, shape in [ + (True, "circle"), + (False, "circle"), + (True, "hexagon"), + (False, "hexagon"), + ]: fig.pygmtlogo( color=color, theme=theme, @@ -114,7 +119,12 @@ # Logo with vertical wordmark. fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame="a1f1g1") for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: - for color, shape in [(True, "circle"), (False, "hexagon")]: + for color, shape in [ + (True, "circle"), + (False, "circle"), + (True, "hexagon"), + (False, "hexagon"), + ]: fig.pygmtlogo( color=color, theme=theme, @@ -129,7 +139,12 @@ # Logo with horizontal wordmark. fig.basemap(region=[0, 20, 0, 13], projection="x1c", frame="a1f1g1") for x, y, theme in [(1, 3, "light"), (11, 3, "dark")]: - for color, shape in [(True, "circle"), (False, "hexagon")]: + for color, shape in [ + (True, "circle"), + (False, "circle"), + (True, "hexagon"), + (False, "hexagon"), + ]: fig.pygmtlogo( color=color, theme=theme, From 858e53289c0853da28f86125449f6f5840ecf58f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 29 Mar 2025 22:08:59 +0100 Subject: [PATCH 169/379] Reorder versions --- examples/gallery/embellishments/pygmt_logo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index beb95217c95..b9655035656 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -101,8 +101,8 @@ for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: for color, shape in [ (True, "circle"), - (False, "circle"), (True, "hexagon"), + (False, "circle"), (False, "hexagon"), ]: fig.pygmtlogo( @@ -121,8 +121,8 @@ for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: for color, shape in [ (True, "circle"), - (False, "circle"), (True, "hexagon"), + (False, "circle"), (False, "hexagon"), ]: fig.pygmtlogo( @@ -141,8 +141,8 @@ for x, y, theme in [(1, 3, "light"), (11, 3, "dark")]: for color, shape in [ (True, "circle"), - (False, "circle"), (True, "hexagon"), + (False, "circle"), (False, "hexagon"), ]: fig.pygmtlogo( From e86f164b57c36863fbcb6879a879973e6cea3887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:20:16 +0200 Subject: [PATCH 170/379] Improve region and projection arguments Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6f35e8c6461..6ef9fa8d884 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -38,6 +38,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Helpful definitions # ----------------------------------------------------------------------------- size = 4 + region = [-size, size] * 2 + projection = "x1c" # Outer and inner radii of compass lines r1, r2 = size * 0.625, size * 0.325 @@ -112,8 +114,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig.plot( x=0, y=0, - region=[-size, size] * 2, - projection=f"X{size * 2}c", + region=region, + projection=projection, style=f"{symbol}{diameter}c", pen=f"15p,{color_blue}", fill=color_bg, From ed4a782d755ec0fceafa7deaa934639bfc92edd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 9 Apr 2025 12:59:05 +0200 Subject: [PATCH 171/379] Adjust pen for arrow Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6ef9fa8d884..b63f368b260 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -117,7 +117,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no region=region, projection=projection, style=f"{symbol}{diameter}c", - pen=f"15p,{color_blue}", + pen=f"0.5c,{color_blue}", fill=color_bg, perspective=perspective, no_clip=True, # needed for corners of hexagon shape From e0ede2e0fbf2ac92d9b183ae6a89c8f5362c9cdd Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 10 Apr 2025 16:18:58 +0200 Subject: [PATCH 172/379] First version of polygon for letter M --- pygmt/src/pygmtlogo.py | 49 +++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index b63f368b260..1b4e798fd41 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -6,6 +6,7 @@ from pathlib import Path +import numpy as np # get ride of the x shift for letter M import pygmt @@ -164,17 +165,45 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # space between letter M and yellow line at the right side # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) - # lines with small distance to horizontal line of letter G - lines_m = [ - ([0.33, 0.90], [1.527, 1.00]), # diagonal left - ([0.90, 1.43], [1.00, 1.527]), # diagonal right - ([0.285, 0.285], [0.30, 1.65]), # vertical left - ([1.47, 1.47], [0.30, 1.65]), # vertical right + + # polygon with small distance to horizontal line of letter G + # starting point: lower right corner of the left vertical line of letter M + # direction: clockwise + m_x1 = 0.35 + m_x2 = 1.52 + m_x = np.array( + [ + m_x1 + m_x1 / 2, # vertical left upwarts + m_x1 - m_x1 / 2, + m_x1 - m_x1 / 2, + m_x1 + m_x1 / 2, + (m_x2 + m_x1 / 2) / 2 + m_x1 / 4, # mid pick above + m_x2 - m_x1 / 2, # vertical right downwarts + m_x2 + m_x1 / 2, + m_x2 + m_x1 / 2, + m_x2 - m_x1 / 2, + m_x2 - m_x1 / 2, # right pick below + (m_x2 + m_x1 / 2) / 2 + m_x1 / 4, # mid pick below + m_x1 + m_x1 / 2, # left pick below + ] + ) # get ride of the x shift + m_y1 = 0.3 + m_y2 = 1.63 + m_y = [ + m_y1, # vertical left upwarts + m_y1, + m_y2, + m_y2, + m_y2 - m_y2 / 4, # mid pick above + m_y2, # vertical right downwarts + m_y2, + m_y1, + m_y1, + m_y2 - m_y2 / 3, # right pick below + m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below + m_y2 - m_y2 / 3, # left pick below ] - for x, y in lines_m: - fig.plot(x=x, y=y, pen=f"10p,{color_red}", perspective=True) - # middle corner - fig.plot(x=0.9, y=0.9, style="d0.3c", fill=color_red, perspective=True) + fig.plot(x=m_x - 0.06, y=m_y, close=True, fill=color_red) # get ride of the x shift # ............................................................................. # letter T From b8d9e8c3ed75b1f2dffdd6d3b1e4a45b9fc1fb31 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 10 Apr 2025 16:44:37 +0200 Subject: [PATCH 173/379] Get ride of the xshift for letter M --- pygmt/src/pygmtlogo.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 1b4e798fd41..ae667981002 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -6,7 +6,6 @@ from pathlib import Path -import numpy as np # get ride of the x shift for letter M import pygmt @@ -169,24 +168,22 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # polygon with small distance to horizontal line of letter G # starting point: lower right corner of the left vertical line of letter M # direction: clockwise - m_x1 = 0.35 - m_x2 = 1.52 - m_x = np.array( - [ - m_x1 + m_x1 / 2, # vertical left upwarts - m_x1 - m_x1 / 2, - m_x1 - m_x1 / 2, - m_x1 + m_x1 / 2, - (m_x2 + m_x1 / 2) / 2 + m_x1 / 4, # mid pick above - m_x2 - m_x1 / 2, # vertical right downwarts - m_x2 + m_x1 / 2, - m_x2 + m_x1 / 2, - m_x2 - m_x1 / 2, - m_x2 - m_x1 / 2, # right pick below - (m_x2 + m_x1 / 2) / 2 + m_x1 / 4, # mid pick below - m_x1 + m_x1 / 2, # left pick below - ] - ) # get ride of the x shift + m_x1 = 0.35 - 0.35 / 2 - 0.06 + m_x2 = 1.52 + 0.35 / 2 - 0.06 + m_x = [ + m_x1 + m_x2 / 5, # vertical left upwarts + m_x1, + m_x1, + m_x1 + m_x2 / 5, + m_x1 + (m_x2 - m_x1) / 2, # mid pick above + m_x2 - m_x2 / 5, # vertical right downwarts + m_x2, + m_x2, + m_x2 - m_x2 / 5, + m_x2 - m_x2 / 5, # right pick below + m_x1 + (m_x2 - m_x1) / 2, # mid pick below + m_x1 + m_x2 / 5, # left pick below + ] m_y1 = 0.3 m_y2 = 1.63 m_y = [ @@ -203,7 +200,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below m_y2 - m_y2 / 3, # left pick below ] - fig.plot(x=m_x - 0.06, y=m_y, close=True, fill=color_red) # get ride of the x shift + fig.plot(x=m_x, y=m_y, close=True, fill=color_red) # ............................................................................. # letter T From 17c350308907a8fc8b48f89f6aea9a300d43f627 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 10 Apr 2025 17:49:38 +0200 Subject: [PATCH 174/379] Fine tune x and y values --- pygmt/src/pygmtlogo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index ae667981002..dcc93d7158c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -168,8 +168,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # polygon with small distance to horizontal line of letter G # starting point: lower right corner of the left vertical line of letter M # direction: clockwise - m_x1 = 0.35 - 0.35 / 2 - 0.06 - m_x2 = 1.52 + 0.35 / 2 - 0.06 + m_x1 = 0.33 - 0.33 / 2 - 0.06 + m_x2 = 1.54 + 0.33 / 2 - 0.06 # outer radius of letter G m_x = [ m_x1 + m_x2 / 5, # vertical left upwarts m_x1, @@ -185,7 +185,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_x1 + m_x2 / 5, # left pick below ] m_y1 = 0.3 - m_y2 = 1.63 + m_y2 = 1.65 # outer radius of letter G m_y = [ m_y1, # vertical left upwarts m_y1, From e432f795ac51ab027e423bdfeb348527cfe56060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 11 Jun 2025 11:58:10 +0200 Subject: [PATCH 175/379] Improve comment --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index dcc93d7158c..db197b9e76a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -223,7 +223,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) - # outline around shape for black and white with dark theme (i.e., white shape) + # outline around the shape for black and white color with dark theme if not color and theme == "dark": fig.plot( x=0, From fae828295f0ca76955b89a06932408b8b6d3be1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:01:19 +0200 Subject: [PATCH 176/379] Use match case for theme Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index db197b9e76a..ca0ac83987f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -64,13 +64,15 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no color_blue = color_yellow = color_red = color_light # background and wordmark - color_bg = color_light - color_py = color_blue - color_gmt = color_dark - if theme == "dark": - color_bg = color_dark - color_py = color_yellow - color_gmt = color_light + match theme: + case "light": + color_bg = color_light + color_py = color_blue + color_gmt = color_dark + case "dark": + color_bg = color_dark + color_py = color_yellow + color_gmt = color_light # ----------------------------------------------------------------------------- # Define shape From e0152260ce88d2a8db7aa3123f16b47082db1c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:02:16 +0200 Subject: [PATCH 177/379] Use case match for shpae Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index ca0ac83987f..eef61e8a2bd 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -77,13 +77,15 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # ----------------------------------------------------------------------------- # Define shape # ----------------------------------------------------------------------------- - symbol = "c" # circle - diameter = 7.5 - diameter_add = 0.5 - if shape == "hexagon": - symbol = "h" # hexagon - diameter = 8.6 - diameter_add = 0.6 + match shape: + case "circle": + symbol = "c" # circle + diameter = 7.5 + diameter_add = 0.5 + case "hexagon": + symbol = "h" # hexagon + diameter = 8.6 + diameter_add = 0.6 # ----------------------------------------------------------------------------- # Define wordmark From aee257415ba96f357500dedd5c29d54ed453f1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:02:37 +0200 Subject: [PATCH 178/379] Use full line length Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index eef61e8a2bd..83cf4cd2966 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -93,19 +93,9 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no font = "AvantGarde-Book" match wordmark: case "vertical": - args_text_wm = { - "x": 0, - "y": -5, - "justify": "CT", - "font": f"2.5c,{font}", - } + args_text_wm = {"x": 0, "y": -5, "justify": "CT", "font": f"2.5c,{font}"} case True | "horizontal": - args_text_wm = { - "x": 6, - "y": 0, - "justify": "LM", - "font": f"8c,{font}", - } + args_text_wm = {"x": 6, "y": 0, "justify": "LM", "font": f"8c,{font}"} # ----------------------------------------------------------------------------- # Start plotting From 2a1464a5c926fcf3f46efcd219c9d7e32f9ec0f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 25 Jul 2025 00:23:12 +0200 Subject: [PATCH 179/379] Save seperation lines Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 83cf4cd2966..68e8ee695b3 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -34,9 +34,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no visual and ``False`` to add no wordmark. """ - # ----------------------------------------------------------------------------- # Helpful definitions - # ----------------------------------------------------------------------------- size = 4 region = [-size, size] * 2 projection = "x1c" @@ -48,9 +46,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Has to be applied to each plotting command, up on second call set to True perspective = "30+w0/0" # Rotation by 30 degrees - # ----------------------------------------------------------------------------- # Define colors - # ----------------------------------------------------------------------------- color_light = "white" color_dark = "gray20" @@ -74,9 +70,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no color_py = color_yellow color_gmt = color_light - # ----------------------------------------------------------------------------- # Define shape - # ----------------------------------------------------------------------------- match shape: case "circle": symbol = "c" # circle @@ -87,9 +81,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no diameter = 8.6 diameter_add = 0.6 - # ----------------------------------------------------------------------------- # Define wordmark - # ----------------------------------------------------------------------------- font = "AvantGarde-Book" match wordmark: case "vertical": @@ -97,9 +89,6 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no case True | "horizontal": args_text_wm = {"x": 6, "y": 0, "justify": "LM", "font": f"8c,{font}"} - # ----------------------------------------------------------------------------- - # Start plotting - # ----------------------------------------------------------------------------- fig = pygmt.Figure() # ............................................................................. @@ -117,9 +106,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no no_clip=True, # needed for corners of hexagon shape ) - # ............................................................................. # yellow lines for compass - # ............................................................................. lines_yellow = [ ([-size, size], [0, 0]), # horizontal line ([-r1, -r2], [r1, r2]), # upper left @@ -130,9 +117,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no for x, y in lines_yellow: fig.plot(x=x, y=y, pen=f"5p,{color_yellow}", perspective=True) - # ............................................................................. # letter G - # ............................................................................. # horizontal red line fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}", perspective=True) # red ring sector @@ -144,17 +129,13 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # cover yellow line in lower part of the ring sector fig.plot(x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red, perspective=True) - # ............................................................................. # upper vertical red line - # ............................................................................. # space between red line and blue circle / hexagon fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}", perspective=True) # red line fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}", perspective=True) - # ............................................................................. # letter M - # ............................................................................. # space between letter M and yellow line at the right side # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) @@ -196,9 +177,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ] fig.plot(x=m_x, y=m_y, close=True, fill=color_red) - # ............................................................................. # letter T - # ............................................................................. # red curved horizontal line fig.plot(x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red, perspective=True) # vertical endings of curved horizontal line @@ -228,16 +207,11 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no no_clip=True, ) - # ............................................................................. # Add wordmark "PyGMT" - # ............................................................................. if wordmark: text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" fig.text(text=text_wm, no_clip=True, **args_text_wm) - # ............................................................................. - # Save - # ............................................................................. fig_name_logo = "pygmt_logo" fig.savefig(fname=f"{fig_name_logo}.eps") From a2c3da8c416937f305d08ee752ade0371019ebe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 25 Jul 2025 00:24:16 +0200 Subject: [PATCH 180/379] Remove seperation lines Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 68e8ee695b3..88d427790e9 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -91,9 +91,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig = pygmt.Figure() - # ............................................................................. # blue circle / hexagon for Earth - # ............................................................................. fig.plot( x=0, y=0, From c46658d2547dbe51b07d7b4a56cb2503e3dfb8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 6 Aug 2025 16:59:54 +0200 Subject: [PATCH 181/379] Fix typo --- pygmt/src/pygmtlogo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 88d427790e9..677c7a983c2 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -144,12 +144,12 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_x1 = 0.33 - 0.33 / 2 - 0.06 m_x2 = 1.54 + 0.33 / 2 - 0.06 # outer radius of letter G m_x = [ - m_x1 + m_x2 / 5, # vertical left upwarts + m_x1 + m_x2 / 5, # vertical left upwards m_x1, m_x1, m_x1 + m_x2 / 5, m_x1 + (m_x2 - m_x1) / 2, # mid pick above - m_x2 - m_x2 / 5, # vertical right downwarts + m_x2 - m_x2 / 5, # vertical right downwards m_x2, m_x2, m_x2 - m_x2 / 5, @@ -160,12 +160,12 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_y1 = 0.3 m_y2 = 1.65 # outer radius of letter G m_y = [ - m_y1, # vertical left upwarts + m_y1, # vertical left upwards m_y1, m_y2, m_y2, m_y2 - m_y2 / 4, # mid pick above - m_y2, # vertical right downwarts + m_y2, # vertical right downwards m_y2, m_y1, m_y1, From f7082c4fc61487a1b9a76c81a492675f7b762a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 6 Aug 2025 17:02:29 +0200 Subject: [PATCH 182/379] Use line length --- pygmt/src/pygmtlogo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 677c7a983c2..a589086c3d5 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -28,10 +28,10 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no Shape of the visual. Use ``"circle"`` for a circle shape [Default] or ``"hexagon"`` for a hexagon shape. wordmark : bool, str - Add the wordmark "PyGMT" and adjust its orientation relative to the visual. - Set to ``True`` or ``"horizontal"``, to add the wordmark at the right side of - the visual [Default]. Use ``"vertical"`` to place the wordmark below the - visual and ``False`` to add no wordmark. + Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set + to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the + visual [Default]. Use ``"vertical"`` to place the wordmark below the visual + and ``False`` to add no wordmark. """ # Helpful definitions From ba7f14de5224135139474204c8beac02716c8a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 6 Aug 2025 17:21:24 +0200 Subject: [PATCH 183/379] Add perspective parameter for letter M --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index a589086c3d5..befa919aace 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -173,7 +173,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below m_y2 - m_y2 / 3, # left pick below ] - fig.plot(x=m_x, y=m_y, close=True, fill=color_red) + fig.plot(x=m_x, y=m_y, close=True, fill=color_red, perspective=True) # letter T # red curved horizontal line From faa61dd061d06108e467d770c0c134bd225df72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 6 Aug 2025 18:06:20 +0200 Subject: [PATCH 184/379] Define radii Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index befa919aace..0df4c96569d 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -39,8 +39,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no region = [-size, size] * 2 projection = "x1c" - # Outer and inner radii of compass lines - r1, r2 = size * 0.625, size * 0.325 + # Radii + r0, r1, r2, r3, r4 = size * np.array([1.0, 0.875, 0.4625, 0.4125, 0.29375]) # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True From b75dbad65e20b9b2873a58c63b3b36bc88a632fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 6 Aug 2025 18:07:28 +0200 Subject: [PATCH 185/379] Improve code for compass Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 0df4c96569d..21f408a262d 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -104,15 +104,18 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no no_clip=True, # needed for corners of hexagon shape ) - # yellow lines for compass - lines_yellow = [ - ([-size, size], [0, 0]), # horizontal line - ([-r1, -r2], [r1, r2]), # upper left - ([-r1, -r2], [-r1, -r2]), # lower left - ([r1, r2], [r1, r2]), # upper right - ([r1, r2], [-r1, -r2]), # lower right - ] - for x, y in lines_yellow: + # Compass + x1, x2 = r1 * 0.7071, r2 * 0.7071 # sqrt(2)/2 = 0.7071 + lines_compass = [ + ([-r0, -r2], [0, 0]), # horizontal lines + ([-r4, 0], [0, 0]), + ([r2, r0], [0, 0]), + ([-x1, -x2], [x1, x2]), # upper left + ([-x1, -x2], [-x1, -x2]), # lower left + ([x1, x2], [x1, x2]), # upper right + ([x1, x2], [-x1, -x2]), # lower right + ] + for x, y in lines_compass: fig.plot(x=x, y=y, pen=f"5p,{color_yellow}", perspective=True) # letter G From 5e345e5c7ab1092bf258f54bb8817efc02f3652f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 6 Aug 2025 18:10:46 +0200 Subject: [PATCH 186/379] Draw letter G via x/y coordinates Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 21f408a262d..b9e0e1bc167 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -118,17 +118,11 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no for x, y in lines_compass: fig.plot(x=x, y=y, pen=f"5p,{color_yellow}", perspective=True) - # letter G - # horizontal red line - fig.plot(x=[0.1, 1.65], y=[0, 0], pen=f"12p,{color_red}", perspective=True) - # red ring sector - fig.plot(x=0, y=0, style="w3.3c/90/0+i2.35c", fill=color_red, perspective=True) - # space between yellow lines and ring sector - fig.plot(x=0, y=0, style="w3.7c/0/360+i3.3c", fill=color_bg, perspective=True) - # vertical yellow line - fig.plot(x=[0, 0], y=[-4, 4], pen=f"6p,{color_yellow}", perspective=True) - # cover yellow line in lower part of the ring sector - fig.plot(x=0, y=0, style="w3.3c/260/-80+i2.35c", fill=color_red, perspective=True) + # Letter G + angles = np.deg2rad(np.arange(90, 361, 1.0)) + x = np.concatenate([np.cos(angles) * r3, [r3, 0, 0, r4], np.cos(np.flip(angles)) * r4]) + y = np.concatenate([np.sin(angles) * r3, [(r3-r4)/2.0, (r3-r4)/2.0, -(r3-r4)/2.0, -(r3-r4)/2.0], np.sin(np.flip(angles)) * r4]) + fig.plot(x=x, y=y, fill=color_red, perspective=True) # upper vertical red line # space between red line and blue circle / hexagon From 3ffbcdff9bc31d549d7f67ee2a64638db0e1631a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 6 Aug 2025 18:13:36 +0200 Subject: [PATCH 187/379] Add numpy import --- pygmt/src/pygmtlogo.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index b9e0e1bc167..676b8e80d01 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -6,6 +6,7 @@ from pathlib import Path +import numpy as np import pygmt @@ -106,22 +107,30 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Compass x1, x2 = r1 * 0.7071, r2 * 0.7071 # sqrt(2)/2 = 0.7071 - lines_compass = [ + lines_compass = [ ([-r0, -r2], [0, 0]), # horizontal lines - ([-r4, 0], [0, 0]), + ([-r4, 0], [0, 0]), ([r2, r0], [0, 0]), ([-x1, -x2], [x1, x2]), # upper left ([-x1, -x2], [-x1, -x2]), # lower left ([x1, x2], [x1, x2]), # upper right ([x1, x2], [-x1, -x2]), # lower right - ] + ] for x, y in lines_compass: fig.plot(x=x, y=y, pen=f"5p,{color_yellow}", perspective=True) # Letter G angles = np.deg2rad(np.arange(90, 361, 1.0)) - x = np.concatenate([np.cos(angles) * r3, [r3, 0, 0, r4], np.cos(np.flip(angles)) * r4]) - y = np.concatenate([np.sin(angles) * r3, [(r3-r4)/2.0, (r3-r4)/2.0, -(r3-r4)/2.0, -(r3-r4)/2.0], np.sin(np.flip(angles)) * r4]) + x = np.concatenate( + [np.cos(angles) * r3, [r3, 0, 0, r4], np.cos(np.flip(angles)) * r4] + ) + y = np.concatenate( + [ + np.sin(angles) * r3, + [(r3 - r4) / 2.0, (r3 - r4) / 2.0, -(r3 - r4) / 2.0, -(r3 - r4) / 2.0], + np.sin(np.flip(angles)) * r4, + ] + ) fig.plot(x=x, y=y, fill=color_red, perspective=True) # upper vertical red line From a5463425a27b8ecd62b2c4394dcd9571f3927f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 3 Nov 2025 22:25:07 +0100 Subject: [PATCH 188/379] Use basemap and allow adding frame and gridlines for debugging Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 676b8e80d01..446518729b2 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -91,17 +91,21 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no args_text_wm = {"x": 6, "y": 0, "justify": "LM", "font": f"8c,{font}"} fig = pygmt.Figure() + fig.basemap( + region=region, + projection=projection, + perspective=perspective, + frame="+n", # Change it to `frame="afg"` for debugging. + ) # blue circle / hexagon for Earth fig.plot( x=0, y=0, - region=region, - projection=projection, style=f"{symbol}{diameter}c", pen=f"0.5c,{color_blue}", fill=color_bg, - perspective=perspective, + perspective=True, no_clip=True, # needed for corners of hexagon shape ) From ec5be4a38982dd29c49d29128cf64ebad5ad28bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 3 Nov 2025 22:36:09 +0100 Subject: [PATCH 189/379] Use variables Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 446518729b2..7b615230ef5 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -139,9 +139,9 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # upper vertical red line # space between red line and blue circle / hexagon - fig.plot(x=[0, 0], y=[4, 3.0], pen=f"18p,{color_bg}", perspective=True) + fig.plot(x=[0, 0], y=[r0, r2], pen=f"18p,{color_bg}", perspective=True) # red line - fig.plot(x=[0, 0], y=[4, 1.9], pen=f"12p,{color_red}", perspective=True) + fig.plot(x=[0, 0], y=[r0, r2], pen=f"12p,{color_red}", perspective=True) # letter M # space between letter M and yellow line at the right side From 0584284b8ea9c3555899d1077793bcbe7fceed65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 3 Nov 2025 22:43:03 +0100 Subject: [PATCH 190/379] Add vertical line back Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 7b615230ef5..4ff9e3a5259 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -115,6 +115,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ([-r0, -r2], [0, 0]), # horizontal lines ([-r4, 0], [0, 0]), ([r2, r0], [0, 0]), + ([0, 0], [-r0, r0]), # vertical line ([-x1, -x2], [x1, x2]), # upper left ([-x1, -x2], [-x1, -x2]), # lower left ([x1, x2], [x1, x2]), # upper right From d66c7b637aee97f647254b3bccef78e726de625b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 4 Nov 2025 08:15:31 +0100 Subject: [PATCH 191/379] Use variable Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4ff9e3a5259..dd37b3087df 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -153,7 +153,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # starting point: lower right corner of the left vertical line of letter M # direction: clockwise m_x1 = 0.33 - 0.33 / 2 - 0.06 - m_x2 = 1.54 + 0.33 / 2 - 0.06 # outer radius of letter G + m_x2 = r3 m_x = [ m_x1 + m_x2 / 5, # vertical left upwards m_x1, From 0949d19ccd44a697df6638a1b32475c3c2f90e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 4 Nov 2025 08:16:19 +0100 Subject: [PATCH 192/379] Use variable (leeter G) Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index dd37b3087df..8e113422039 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -169,7 +169,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_x1 + m_x2 / 5, # left pick below ] m_y1 = 0.3 - m_y2 = 1.65 # outer radius of letter G + m_y2 = r3 m_y = [ m_y1, # vertical left upwards m_y1, From bb3bf233e592e8b0534088c4fe39d1d122aa9c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 4 Nov 2025 08:18:59 +0100 Subject: [PATCH 193/379] Use half of the pen thickness of compass lines for Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 8e113422039..39c305251b0 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -152,7 +152,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # polygon with small distance to horizontal line of letter G # starting point: lower right corner of the left vertical line of letter M # direction: clockwise - m_x1 = 0.33 - 0.33 / 2 - 0.06 + m_x1 = 5 / 2.0 / 72 * 2.54 # Half of the pen thickness of compass lines. m_x2 = r3 m_x = [ m_x1 + m_x2 / 5, # vertical left upwards From ee94768006a2d03640f613677fc0405c51a2535a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 4 Nov 2025 08:20:24 +0100 Subject: [PATCH 194/379] Calculate the position of letter M (sligthly above letter G) Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 39c305251b0..6ce9dc9d693 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -168,7 +168,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_x1 + (m_x2 - m_x1) / 2, # mid pick below m_x1 + m_x2 / 5, # left pick below ] - m_y1 = 0.3 + m_y1 = (r3 - r4) / 2.0 * 1.2 m_y2 = r3 m_y = [ m_y1, # vertical left upwards From 9072f0d1a7b08da9334428349cff5df2733beb84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 4 Nov 2025 08:21:16 +0100 Subject: [PATCH 195/379] Add extra vertical compass line above letters "G" and "M" Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6ce9dc9d693..e782f895167 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -204,6 +204,10 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ) # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) + + # Extra vertical compass line above letters "G" and "M". + fig.plot(x=[0, 0], y=[-r4 * 0.9, r2], pen=f"5p,{color_yellow}", perspective=True) + # outline around the shape for black and white color with dark theme if not color and theme == "dark": From a98d25c81c256ac2a0621044b17415bcef166db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 4 Nov 2025 08:31:10 +0100 Subject: [PATCH 196/379] Remove not needed return value --- pygmt/src/pygmtlogo.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e782f895167..c3655e29f9c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -23,8 +23,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no Set to ``True`` to use colors referring to Python (blue and yellow) and GMT (red) [Default]. For ``False``, the logo is drawn in black and white. theme : str - Use ``"light"`` for light mode (i.e., white background) [Default] and ``"dark"`` - for dark mode (i.e., darkgray [gray20] background). + Use ``"light"`` for light mode (i.e., a white background) [Default] and + ``"dark"`` for dark mode (i.e., a darkgray [gray20] background). shape : str Shape of the visual. Use ``"circle"`` for a circle shape [Default] or ``"hexagon"`` for a hexagon shape. @@ -92,9 +92,9 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig = pygmt.Figure() fig.basemap( - region=region, - projection=projection, - perspective=perspective, + region=region, + projection=projection, + perspective=perspective, frame="+n", # Change it to `frame="afg"` for debugging. ) @@ -204,11 +204,10 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ) # arrow tail fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) - + # Extra vertical compass line above letters "G" and "M". fig.plot(x=[0, 0], y=[-r4 * 0.9, r2], pen=f"5p,{color_yellow}", perspective=True) - # outline around the shape for black and white color with dark theme if not color and theme == "dark": fig.plot( @@ -228,7 +227,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig_name_logo = "pygmt_logo" fig.savefig(fname=f"{fig_name_logo}.eps") - return fig_name_logo, color_bg + return fig_name_logo def pygmtlogo( # noqa: PLR0913 @@ -252,7 +251,7 @@ def pygmtlogo( # noqa: PLR0913 # ----------------------------------------------------------------------------- # Create logo file # ----------------------------------------------------------------------------- - fig_name_logo, color_bg = create_logo( + fig_name_logo = create_logo( color=color, theme=theme, shape=shape, wordmark=wordmark ) From b9de084d34edaeb82805371d2b5d5730960b22c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 4 Nov 2025 12:44:28 +0100 Subject: [PATCH 197/379] Improve plotting the curved horizontal line and the arrow Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index c3655e29f9c..51850f6a12e 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -186,24 +186,20 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ] fig.plot(x=m_x, y=m_y, close=True, fill=color_red, perspective=True) - # letter T - # red curved horizontal line - fig.plot(x=0, y=0, style="w4.6c/240/-60+i3.7c", fill=color_red, perspective=True) - # vertical endings of curved horizontal line - args_vert = {"y": [-1.5, -2.5], "pen": f"9p,{color_bg}", "perspective": True} - fig.plot(x=[-1.05, -1.05], **args_vert) - fig.plot(x=[1.05, 1.05], **args_vert) - # arrow head as inverse triangle with pen for space to blue circle / hexagon - fig.plot( - x=0, - y=-3.55, - style="i1.1c", - fill=color_red, - pen=f"3p,{color_bg}", - perspective=True, - ) - # arrow tail - fig.plot(x=[0, 0], y=[-2, -3.57], pen=f"12p,{color_red}", perspective=True) + # Letter T + # Red curved horizontal line + angles = np.deg2rad(np.arange(150, 210, 0.1)) + t_x = np.concatenate([r2 * np.sin(angles), (r2 + (r3-r4))* np.sin(np.flip(angles))]) + t_y = np.concatenate([r2 * np.cos(angles), (r2 + (r3-r4)) * np.cos(np.flip(angles))]) + # Ensure the same X coordinate for the right edge of T and the middle of M. + mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2.0) + fig.plot(x=t_x[mask], y=t_y[mask], fill=color_red) + # The arrow + fig.plot(data=[[0, -r2, 0, -r0 * 1.05]], pen=color_bg, + style=f"v0.8c+s+e+h0+a60+g{color_bg}", perspective=True) + fig.plot(data=[[0, -r2, 0, -r0]], pen=f"12p,{color_red}", + style=f"v0.75c+s+e+h0+a60+g{color_red}", perspective=True) + # Extra vertical compass line above letters "G" and "M". fig.plot(x=[0, 0], y=[-r4 * 0.9, r2], pen=f"5p,{color_yellow}", perspective=True) From 4b8e3b61b729fdc505a0650b12dde5b1aa8f1728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 4 Nov 2025 14:35:23 +0100 Subject: [PATCH 198/379] Add background color --- examples/gallery/embellishments/pygmt_logo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index b9655035656..3773537f4e2 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -97,7 +97,7 @@ fig = pygmt.Figure() # Logo without workmark. -fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame="a1f1g1") +fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame=["a1f1g1", "+gtan"]) for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: for color, shape in [ (True, "circle"), @@ -117,7 +117,7 @@ fig.shift_origin(xshift=8) # Logo with vertical wordmark. -fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame="a1f1g1") +fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame=["a1f1g1", "+gtan"]) for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: for color, shape in [ (True, "circle"), @@ -137,7 +137,7 @@ fig.shift_origin(xshift=8) # Logo with horizontal wordmark. -fig.basemap(region=[0, 20, 0, 13], projection="x1c", frame="a1f1g1") +fig.basemap(region=[0, 20, 0, 13], projection="x1c", frame=["a1f1g1", "+gtan"]) for x, y, theme in [(1, 3, "light"), (11, 3, "dark")]: for color, shape in [ (True, "circle"), From 29910ac89f0ef36cfaf8940f2e487d57d8f714a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 4 Nov 2025 14:35:48 +0100 Subject: [PATCH 199/379] Follow line length limit --- pygmt/src/pygmtlogo.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 51850f6a12e..9ce33f347e6 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -189,17 +189,28 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Letter T # Red curved horizontal line angles = np.deg2rad(np.arange(150, 210, 0.1)) - t_x = np.concatenate([r2 * np.sin(angles), (r2 + (r3-r4))* np.sin(np.flip(angles))]) - t_y = np.concatenate([r2 * np.cos(angles), (r2 + (r3-r4)) * np.cos(np.flip(angles))]) + t_x = np.concatenate( + [r2 * np.sin(angles), (r2 + (r3 - r4)) * np.sin(np.flip(angles))] + ) + t_y = np.concatenate( + [r2 * np.cos(angles), (r2 + (r3 - r4)) * np.cos(np.flip(angles))] + ) # Ensure the same X coordinate for the right edge of T and the middle of M. mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2.0) fig.plot(x=t_x[mask], y=t_y[mask], fill=color_red) # The arrow - fig.plot(data=[[0, -r2, 0, -r0 * 1.05]], pen=color_bg, - style=f"v0.8c+s+e+h0+a60+g{color_bg}", perspective=True) - fig.plot(data=[[0, -r2, 0, -r0]], pen=f"12p,{color_red}", - style=f"v0.75c+s+e+h0+a60+g{color_red}", perspective=True) - + fig.plot( + data=[[0, -r2, 0, -r0 * 1.05]], + pen=color_bg, + style=f"v0.8c+s+e+h0+a60+g{color_bg}", + perspective=True, + ) + fig.plot( + data=[[0, -r2, 0, -r0]], + pen=f"12p,{color_red}", + style=f"v0.75c+s+e+h0+a60+g{color_red}", + perspective=True, + ) # Extra vertical compass line above letters "G" and "M". fig.plot(x=[0, 0], y=[-r4 * 0.9, r2], pen=f"5p,{color_yellow}", perspective=True) From aa6d9363c56bd19ae1a29156b90869b47f768f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 4 Nov 2025 20:16:02 +0100 Subject: [PATCH 200/379] Add perspective parameter for curved horizontal line of letter T --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 9ce33f347e6..edd083c8c1f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -197,7 +197,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ) # Ensure the same X coordinate for the right edge of T and the middle of M. mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2.0) - fig.plot(x=t_x[mask], y=t_y[mask], fill=color_red) + fig.plot(x=t_x[mask], y=t_y[mask], fill=color_red, perspective=True) # The arrow fig.plot( data=[[0, -r2, 0, -r0 * 1.05]], From 7cab1bb0761c558c0534ce5254d640f2e17a2b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 4 Nov 2025 20:42:14 +0100 Subject: [PATCH 201/379] Introduce radius for outer limit of curved horizontal line for letter T --- pygmt/src/pygmtlogo.py | 53 +++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index edd083c8c1f..09fcfe09814 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -41,11 +41,13 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no projection = "x1c" # Radii - r0, r1, r2, r3, r4 = size * np.array([1.0, 0.875, 0.4625, 0.4125, 0.29375]) + r0, r1, r2, r3, r4, r5 = size * np.array( + [1.0, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] + ) # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True - perspective = "30+w0/0" # Rotation by 30 degrees + perspective = "30+w0/0" # Rotation around the center by 30 degrees ccw # Define colors color_light = "white" @@ -110,11 +112,11 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ) # Compass - x1, x2 = r1 * 0.7071, r2 * 0.7071 # sqrt(2)/2 = 0.7071 + x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 lines_compass = [ - ([-r0, -r2], [0, 0]), # horizontal lines - ([-r4, 0], [0, 0]), - ([r2, r0], [0, 0]), + ([-r0, -r3], [0, 0]), # horizontal lines + ([-r5, 0], [0, 0]), + ([r3, r0], [0, 0]), ([0, 0], [-r0, r0]), # vertical line ([-x1, -x2], [x1, x2]), # upper left ([-x1, -x2], [-x1, -x2]), # lower left @@ -127,22 +129,22 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Letter G angles = np.deg2rad(np.arange(90, 361, 1.0)) x = np.concatenate( - [np.cos(angles) * r3, [r3, 0, 0, r4], np.cos(np.flip(angles)) * r4] + [np.cos(angles) * r4, [r4, 0, 0, r5], np.cos(np.flip(angles)) * r5] ) y = np.concatenate( [ - np.sin(angles) * r3, - [(r3 - r4) / 2.0, (r3 - r4) / 2.0, -(r3 - r4) / 2.0, -(r3 - r4) / 2.0], - np.sin(np.flip(angles)) * r4, + np.sin(angles) * r4, + [(r4 - r5) / 2.0, (r4 - r5) / 2.0, -(r4 - r5) / 2.0, -(r4 - r5) / 2.0], + np.sin(np.flip(angles)) * r5, ] ) fig.plot(x=x, y=y, fill=color_red, perspective=True) # upper vertical red line # space between red line and blue circle / hexagon - fig.plot(x=[0, 0], y=[r0, r2], pen=f"18p,{color_bg}", perspective=True) + fig.plot(x=[0, 0], y=[r0, r3], pen=f"18p,{color_bg}", perspective=True) # red line - fig.plot(x=[0, 0], y=[r0, r2], pen=f"12p,{color_red}", perspective=True) + fig.plot(x=[0, 0], y=[r0, r3], pen=f"12p,{color_red}", perspective=True) # letter M # space between letter M and yellow line at the right side @@ -153,7 +155,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # starting point: lower right corner of the left vertical line of letter M # direction: clockwise m_x1 = 5 / 2.0 / 72 * 2.54 # Half of the pen thickness of compass lines. - m_x2 = r3 + m_x2 = r4 m_x = [ m_x1 + m_x2 / 5, # vertical left upwards m_x1, @@ -168,8 +170,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_x1 + (m_x2 - m_x1) / 2, # mid pick below m_x1 + m_x2 / 5, # left pick below ] - m_y1 = (r3 - r4) / 2.0 * 1.2 - m_y2 = r3 + m_y1 = (r4 - r5) / 2.0 * 1.2 + m_y2 = r4 m_y = [ m_y1, # vertical left upwards m_y1, @@ -189,31 +191,27 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Letter T # Red curved horizontal line angles = np.deg2rad(np.arange(150, 210, 0.1)) - t_x = np.concatenate( - [r2 * np.sin(angles), (r2 + (r3 - r4)) * np.sin(np.flip(angles))] - ) - t_y = np.concatenate( - [r2 * np.cos(angles), (r2 + (r3 - r4)) * np.cos(np.flip(angles))] - ) + t_x = np.concatenate([r3 * np.sin(angles), r2 * np.sin(np.flip(angles))]) + t_y = np.concatenate([r3 * np.cos(angles), r2 * np.cos(np.flip(angles))]) # Ensure the same X coordinate for the right edge of T and the middle of M. mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2.0) fig.plot(x=t_x[mask], y=t_y[mask], fill=color_red, perspective=True) # The arrow fig.plot( - data=[[0, -r2, 0, -r0 * 1.05]], + data=[[0, -r3, 0, -r0 * 1.05]], pen=color_bg, style=f"v0.8c+s+e+h0+a60+g{color_bg}", perspective=True, ) fig.plot( - data=[[0, -r2, 0, -r0]], + data=[[0, -r3, 0, -r0]], pen=f"12p,{color_red}", style=f"v0.75c+s+e+h0+a60+g{color_red}", perspective=True, ) # Extra vertical compass line above letters "G" and "M". - fig.plot(x=[0, 0], y=[-r4 * 0.9, r2], pen=f"5p,{color_yellow}", perspective=True) + fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"5p,{color_yellow}", perspective=True) # outline around the shape for black and white color with dark theme if not color and theme == "dark": @@ -231,6 +229,13 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no 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 + # 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.8p,black,dashed") + # Map frame with annotations, tick marks, and gridlines + fig.basemap(frame="a1fg1", perspective=True) + fig_name_logo = "pygmt_logo" fig.savefig(fname=f"{fig_name_logo}.eps") From 039bad459fab18630ed02c00ea14dbfaace57754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 4 Nov 2025 21:11:48 +0100 Subject: [PATCH 202/379] Remove frame and circles for orientation --- pygmt/src/pygmtlogo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 09fcfe09814..8d1d517862f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -231,10 +231,10 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Helpful for implementing the logo; not included in the logo # 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.8p,black,dashed") + # for r in [r0, r1, r2, r3, r4, r5]: + # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") # Map frame with annotations, tick marks, and gridlines - fig.basemap(frame="a1fg1", perspective=True) + # fig.basemap(frame="a1fg1", perspective=True) fig_name_logo = "pygmt_logo" fig.savefig(fname=f"{fig_name_logo}.eps") From 3e8ae2141de4fd3a507bdb34da9acfa8525067d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 4 Nov 2025 21:25:01 +0100 Subject: [PATCH 203/379] Update parameter names in tests --- pygmt/tests/test_pygmtlogo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index a632ac13427..8e6803298d9 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -42,11 +42,11 @@ def test_pylogo_no_wordmark(): @pytest.mark.mpl_image_compare def test_pylogo_lightmode(): """ - Plot the PyGMT logo in light mode. + Plot the PyGMT logo in dark mode. """ fig = Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) - fig.pygmtlogo(darkmode=False) + fig.pygmtlogo(theme="dark") return fig @@ -57,5 +57,5 @@ def test_pylogo_vertical(): """ fig = Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) - fig.pygmtlogo(orientation="vertical") + fig.pygmtlogo(wordmark="vertical") return fig From 12be397e3471516db4697ef8e38c418977eedce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 4 Nov 2025 21:28:02 +0100 Subject: [PATCH 204/379] Remove tab by white spaces --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 8d1d517862f..d87aea825a7 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -232,7 +232,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Helpful for implementing the logo; not included in the logo # 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.8p,black,dashed") + # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") # Map frame with annotations, tick marks, and gridlines # fig.basemap(frame="a1fg1", perspective=True) From 5453d165bc7f7cff297ca7e3e4f8dbd97a24023f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 5 Nov 2025 09:22:12 +0100 Subject: [PATCH 205/379] Remove unneeded comment Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d87aea825a7..c8001bc6831 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -97,7 +97,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no region=region, projection=projection, perspective=perspective, - frame="+n", # Change it to `frame="afg"` for debugging. + frame="+n", ) # blue circle / hexagon for Earth From 19c0d18598efc52ff579a27f0fbaf7740bc975cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 5 Nov 2025 09:25:15 +0100 Subject: [PATCH 206/379] Adjust length of vertical line of compass Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index c8001bc6831..0406f1596c8 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -117,7 +117,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ([-r0, -r3], [0, 0]), # horizontal lines ([-r5, 0], [0, 0]), ([r3, r0], [0, 0]), - ([0, 0], [-r0, r0]), # vertical line + ([0, 0], [-r3, r3]), # vertical line ([-x1, -x2], [x1, x2]), # upper left ([-x1, -x2], [-x1, -x2]), # lower left ([x1, x2], [x1, x2]), # upper right From a272a096e63486e46f44b68d8d25292e66d5d507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 5 Nov 2025 16:54:28 +0100 Subject: [PATCH 207/379] Adjust compass line ending at upper right corner of letter M --- pygmt/src/pygmtlogo.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 0406f1596c8..3d2da28970b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -120,7 +120,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ([0, 0], [-r3, r3]), # vertical line ([-x1, -x2], [x1, x2]), # upper left ([-x1, -x2], [-x1, -x2]), # lower left - ([x1, x2], [x1, x2]), # upper right + ([x1, x2 + (r4 - r5)], [x1, x2 + (r4 - r5)]), # upper right ([x1, x2], [-x1, -x2]), # lower right ] for x, y in lines_compass: @@ -147,10 +147,6 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig.plot(x=[0, 0], y=[r0, r3], pen=f"12p,{color_red}", perspective=True) # letter M - # space between letter M and yellow line at the right side - # fig.plot(x=[1.6, 1.6], y=[1.5, 1.775], pen=f"10p,{color_bg}") - fig.plot(x=[1.6, 1.6], y=[1.5, 2.0], pen=f"10p,{color_bg}", perspective=True) - # polygon with small distance to horizontal line of letter G # starting point: lower right corner of the left vertical line of letter M # direction: clockwise From 4bd81303824c0316ae5aa9d6f414869a554d55fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:32:37 +0100 Subject: [PATCH 208/379] Define pen thickness Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 3d2da28970b..d20927c5760 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -44,6 +44,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no r0, r1, r2, r3, r4, r5 = size * np.array( [1.0, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] ) + thick = (r0 - r1) # Thick pen in cm + thin = thick / 3.0 # Thin pen in cm # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True @@ -77,8 +79,8 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no match shape: case "circle": symbol = "c" # circle - diameter = 7.5 - diameter_add = 0.5 + diameter = r0 + r1 + diameter_add = r0 - r1 case "hexagon": symbol = "h" # hexagon diameter = 8.6 @@ -105,7 +107,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no x=0, y=0, style=f"{symbol}{diameter}c", - pen=f"0.5c,{color_blue}", + pen=f"{thick}c,{color_blue}", fill=color_bg, perspective=True, no_clip=True, # needed for corners of hexagon shape @@ -124,7 +126,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ([x1, x2], [-x1, -x2]), # lower right ] for x, y in lines_compass: - fig.plot(x=x, y=y, pen=f"5p,{color_yellow}", perspective=True) + fig.plot(x=x, y=y, pen=f"{thin}c,{color_yellow}", perspective=True) # Letter G angles = np.deg2rad(np.arange(90, 361, 1.0)) @@ -142,15 +144,15 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # upper vertical red line # space between red line and blue circle / hexagon - fig.plot(x=[0, 0], y=[r0, r3], pen=f"18p,{color_bg}", perspective=True) + fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick * 1.5}c,{color_bg}", perspective=True) # red line - fig.plot(x=[0, 0], y=[r0, r3], pen=f"12p,{color_red}", perspective=True) + fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick}c,{color_red}", perspective=True) # letter M # polygon with small distance to horizontal line of letter G # starting point: lower right corner of the left vertical line of letter M # direction: clockwise - m_x1 = 5 / 2.0 / 72 * 2.54 # Half of the pen thickness of compass lines. + m_x1 = thin / 2.0 # Half of the pen thickness of compass lines. m_x2 = r4 m_x = [ m_x1 + m_x2 / 5, # vertical left upwards @@ -196,13 +198,13 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig.plot( data=[[0, -r3, 0, -r0 * 1.05]], pen=color_bg, - style=f"v0.8c+s+e+h0+a60+g{color_bg}", + style=f"v{thick * 1.6}c+s+e+h0+a60+g{color_bg}", perspective=True, ) fig.plot( data=[[0, -r3, 0, -r0]], - pen=f"12p,{color_red}", - style=f"v0.75c+s+e+h0+a60+g{color_red}", + pen=f"{thick}c,{color_red}", + style=f"v{thick * 1.5}c+s+e+h0+a60+g{color_red}", perspective=True, ) From 193f725dcb687296e88036ea4b91f4f4e31cf27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 6 Nov 2025 16:40:40 +0100 Subject: [PATCH 209/379] Fix code of orientation circles --- pygmt/src/pygmtlogo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d20927c5760..697b1a0aa55 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -44,7 +44,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no r0, r1, r2, r3, r4, r5 = size * np.array( [1.0, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] ) - thick = (r0 - r1) # Thick pen in cm + thick = r0 - r1 # Thick pen in cm thin = thick / 3.0 # Thin pen in cm # Rotation around z (vertical) axis placed in the center @@ -229,10 +229,10 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Helpful for implementing the logo; not included in the logo # 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.8p,black,dashed") + # for r in [r0, r1, r2, r3, r4, r5, r2 + (r3 - r4)]: + # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") # Map frame with annotations, tick marks, and gridlines - # fig.basemap(frame="a1fg1", perspective=True) + # fig.basemap(frame="g1", perspective=True) fig_name_logo = "pygmt_logo" fig.savefig(fname=f"{fig_name_logo}.eps") From 22ecb94f4a738b21600c2ef68a595f76f759eeef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 7 Nov 2025 19:19:48 +0100 Subject: [PATCH 210/379] Improve some comments --- pygmt/src/pygmtlogo.py | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 697b1a0aa55..4a2868279dd 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -55,7 +55,6 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no color_light = "white" color_dark = "gray20" - # visual color_blue = "48/105/152" # Python blue color_yellow = "255/212/59" # Python yellow color_red = "238/86/52" # GMT red @@ -64,7 +63,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no if theme == "dark": color_blue = color_yellow = color_red = color_light - # background and wordmark + # Background and wordmark match theme: case "light": color_bg = color_light @@ -102,7 +101,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no frame="+n", ) - # blue circle / hexagon for Earth + # Blue circle / hexagon for Earth fig.plot( x=0, y=0, @@ -112,6 +111,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no perspective=True, no_clip=True, # needed for corners of hexagon shape ) + fig.show() # Compass x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 @@ -127,6 +127,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ] for x, y in lines_compass: fig.plot(x=x, y=y, pen=f"{thin}c,{color_yellow}", perspective=True) + fig.show() # Letter G angles = np.deg2rad(np.arange(90, 361, 1.0)) @@ -141,17 +142,20 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ] ) fig.plot(x=x, y=y, fill=color_red, perspective=True) + fig.show() - # upper vertical red line - # space between red line and blue circle / hexagon + # Upper vertical red line + # Space between red line and blue circle / hexagon fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick * 1.5}c,{color_bg}", perspective=True) + fig.show() # red line fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick}c,{color_red}", perspective=True) + fig.show() - # letter M - # polygon with small distance to horizontal line of letter G - # starting point: lower right corner of the left vertical line of letter M - # direction: clockwise + # Letter M + # Polygon with small distance to horizontal line of letter G + # Starting point: lower right corner of the left vertical line of letter M + # Direction: clockwise m_x1 = thin / 2.0 # Half of the pen thickness of compass lines. m_x2 = r4 m_x = [ @@ -185,6 +189,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_y2 - m_y2 / 3, # left pick below ] fig.plot(x=m_x, y=m_y, close=True, fill=color_red, perspective=True) + fig.show() # Letter T # Red curved horizontal line @@ -194,6 +199,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Ensure the same X coordinate for the right edge of T and the middle of M. mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2.0) fig.plot(x=t_x[mask], y=t_y[mask], fill=color_red, perspective=True) + fig.show() # The arrow fig.plot( data=[[0, -r3, 0, -r0 * 1.05]], @@ -201,17 +207,20 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no style=f"v{thick * 1.6}c+s+e+h0+a60+g{color_bg}", perspective=True, ) + fig.show() fig.plot( data=[[0, -r3, 0, -r0]], pen=f"{thick}c,{color_red}", style=f"v{thick * 1.5}c+s+e+h0+a60+g{color_red}", perspective=True, ) + fig.show() - # Extra vertical compass line above letters "G" and "M". + # Extra vertical compass line above letters G and M. fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"5p,{color_yellow}", perspective=True) + fig.show() - # outline around the shape for black and white color with dark theme + # Outline around the shape for black and white color with dark theme if not color and theme == "dark": fig.plot( x=0, @@ -221,19 +230,23 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no perspective=True, no_clip=True, ) + fig.show() # Add wordmark "PyGMT" if wordmark: text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" fig.text(text=text_wm, no_clip=True, **args_text_wm) + fig.show() # Helpful for implementing the logo; not included in the logo # Circles for the different radii - # for r in [r0, r1, r2, r3, r4, r5, r2 + (r3 - r4)]: - # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") + for r in [r0, r1, r2, r3, r4, r5, r2 + (r3 - r4)]: + fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") # Map frame with annotations, tick marks, and gridlines - # fig.basemap(frame="g1", perspective=True) + with pygmt.config(MAP_FRAME_TYPE="inside"): + fig.basemap(frame="a1g1") + fig.show() fig_name_logo = "pygmt_logo" fig.savefig(fname=f"{fig_name_logo}.eps") From ef619bc53aa6ade48b0ea8e74a94503317cc9c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 7 Nov 2025 19:20:38 +0100 Subject: [PATCH 211/379] Plot only lower part of vertical compass line --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4a2868279dd..b8c95e64078 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -113,13 +113,13 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ) fig.show() - # Compass + # Compass (plot vertical line on top of letters G and M again at the end) x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 lines_compass = [ ([-r0, -r3], [0, 0]), # horizontal lines ([-r5, 0], [0, 0]), ([r3, r0], [0, 0]), - ([0, 0], [-r3, r3]), # vertical line + ([0, 0], [-r3, 0]), # vertical line ([-x1, -x2], [x1, x2]), # upper left ([-x1, -x2], [-x1, -x2]), # lower left ([x1, x2 + (r4 - r5)], [x1, x2 + (r4 - r5)]), # upper right From 255f7feb331f0fa6e0af25c11883fd4837dcc30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 7 Nov 2025 19:22:37 +0100 Subject: [PATCH 212/379] Use a slightly smaller arrow head for letter T --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index b8c95e64078..8f1dd5da1a3 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -211,7 +211,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig.plot( data=[[0, -r3, 0, -r0]], pen=f"{thick}c,{color_red}", - style=f"v{thick * 1.5}c+s+e+h0+a60+g{color_red}", + style=f"v{thick * 1.4}c+s+e+h0+a60+g{color_red}", perspective=True, ) fig.show() From 94f09d7dfc19f8b88effb48fdae76305a6eef40c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 7 Nov 2025 19:34:22 +0100 Subject: [PATCH 213/379] Remove 'color' from variable names --- pygmt/src/pygmtlogo.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 8f1dd5da1a3..2638c606f89 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -55,23 +55,23 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no color_light = "white" color_dark = "gray20" - color_blue = "48/105/152" # Python blue - color_yellow = "255/212/59" # Python yellow - color_red = "238/86/52" # GMT red + blue = "48/105/152" # Python blue + yellow = "255/212/59" # Python yellow + red = "238/86/52" # GMT red if not color: - color_blue = color_yellow = color_red = color_dark + blue = yellow = red = color_dark if theme == "dark": - color_blue = color_yellow = color_red = color_light + blue = yellow = red = color_light # Background and wordmark match theme: case "light": color_bg = color_light - color_py = color_blue + color_py = blue color_gmt = color_dark case "dark": color_bg = color_dark - color_py = color_yellow + color_py = yellow color_gmt = color_light # Define shape @@ -106,7 +106,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no x=0, y=0, style=f"{symbol}{diameter}c", - pen=f"{thick}c,{color_blue}", + pen=f"{thick}c,{blue}", fill=color_bg, perspective=True, no_clip=True, # needed for corners of hexagon shape @@ -126,7 +126,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ([x1, x2], [-x1, -x2]), # lower right ] for x, y in lines_compass: - fig.plot(x=x, y=y, pen=f"{thin}c,{color_yellow}", perspective=True) + fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) fig.show() # Letter G @@ -141,7 +141,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no np.sin(np.flip(angles)) * r5, ] ) - fig.plot(x=x, y=y, fill=color_red, perspective=True) + fig.plot(x=x, y=y, fill=red, perspective=True) fig.show() # Upper vertical red line @@ -149,7 +149,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick * 1.5}c,{color_bg}", perspective=True) fig.show() # red line - fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick}c,{color_red}", perspective=True) + fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick}c,{red}", perspective=True) fig.show() # Letter M @@ -188,7 +188,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below m_y2 - m_y2 / 3, # left pick below ] - fig.plot(x=m_x, y=m_y, close=True, fill=color_red, perspective=True) + fig.plot(x=m_x, y=m_y, close=True, fill=red, perspective=True) fig.show() # Letter T @@ -198,7 +198,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no t_y = np.concatenate([r3 * np.cos(angles), r2 * np.cos(np.flip(angles))]) # Ensure the same X coordinate for the right edge of T and the middle of M. mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2.0) - fig.plot(x=t_x[mask], y=t_y[mask], fill=color_red, perspective=True) + fig.plot(x=t_x[mask], y=t_y[mask], fill=red, perspective=True) fig.show() # The arrow fig.plot( @@ -210,14 +210,14 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig.show() fig.plot( data=[[0, -r3, 0, -r0]], - pen=f"{thick}c,{color_red}", - style=f"v{thick * 1.4}c+s+e+h0+a60+g{color_red}", + pen=f"{thick}c,{red}", + style=f"v{thick * 1.4}c+s+e+h0+a60+g{red}", perspective=True, ) fig.show() # Extra vertical compass line above letters G and M. - fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"5p,{color_yellow}", perspective=True) + fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"5p,{yellow}", perspective=True) fig.show() # Outline around the shape for black and white color with dark theme From 7afd52ea457af7419b41d1d2eac0f2426c0cc33f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 7 Nov 2025 19:47:28 +0100 Subject: [PATCH 214/379] Add just radius for arrow Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 2638c606f89..10d45ac99b7 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -202,7 +202,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no fig.show() # The arrow fig.plot( - data=[[0, -r3, 0, -r0 * 1.05]], + data=[[0, -r2, 0, -r0 * 1.05]], pen=color_bg, style=f"v{thick * 1.6}c+s+e+h0+a60+g{color_bg}", perspective=True, From f994c9ad7929433dcefe6bdf8f86ff5e6e3f2bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 7 Nov 2025 20:44:33 +0100 Subject: [PATCH 215/379] Out-comment fig.show --- pygmt/src/pygmtlogo.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 10d45ac99b7..0d8e0d68940 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -111,7 +111,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no perspective=True, no_clip=True, # needed for corners of hexagon shape ) - fig.show() + # fig.show() # Compass (plot vertical line on top of letters G and M again at the end) x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 @@ -127,7 +127,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ] for x, y in lines_compass: fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) - fig.show() + # fig.show() # Letter G angles = np.deg2rad(np.arange(90, 361, 1.0)) @@ -142,15 +142,15 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ] ) fig.plot(x=x, y=y, fill=red, perspective=True) - fig.show() + # fig.show() # Upper vertical red line # Space between red line and blue circle / hexagon fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick * 1.5}c,{color_bg}", perspective=True) - fig.show() + # fig.show() # red line fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick}c,{red}", perspective=True) - fig.show() + # fig.show() # Letter M # Polygon with small distance to horizontal line of letter G @@ -189,7 +189,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_y2 - m_y2 / 3, # left pick below ] fig.plot(x=m_x, y=m_y, close=True, fill=red, perspective=True) - fig.show() + # fig.show() # Letter T # Red curved horizontal line @@ -199,7 +199,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Ensure the same X coordinate for the right edge of T and the middle of M. mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2.0) fig.plot(x=t_x[mask], y=t_y[mask], fill=red, perspective=True) - fig.show() + # fig.show() # The arrow fig.plot( data=[[0, -r2, 0, -r0 * 1.05]], @@ -207,18 +207,18 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no style=f"v{thick * 1.6}c+s+e+h0+a60+g{color_bg}", perspective=True, ) - fig.show() + # fig.show() fig.plot( data=[[0, -r3, 0, -r0]], pen=f"{thick}c,{red}", style=f"v{thick * 1.4}c+s+e+h0+a60+g{red}", perspective=True, ) - fig.show() + # fig.show() # Extra vertical compass line above letters G and M. fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"5p,{yellow}", perspective=True) - fig.show() + # fig.show() # Outline around the shape for black and white color with dark theme if not color and theme == "dark": @@ -230,13 +230,13 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no perspective=True, no_clip=True, ) - fig.show() + # fig.show() # Add wordmark "PyGMT" if wordmark: text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" fig.text(text=text_wm, no_clip=True, **args_text_wm) - fig.show() + # fig.show() # Helpful for implementing the logo; not included in the logo # Circles for the different radii From f4269bb731aa9c8c0f933baeeacbefa6a604c876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 7 Nov 2025 21:27:38 +0100 Subject: [PATCH 216/379] Adjust position of horizontal wordmark --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 0d8e0d68940..4ded27f8bdd 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -91,7 +91,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no case "vertical": args_text_wm = {"x": 0, "y": -5, "justify": "CT", "font": f"2.5c,{font}"} case True | "horizontal": - args_text_wm = {"x": 6, "y": 0, "justify": "LM", "font": f"8c,{font}"} + args_text_wm = {"x": 4.5, "y": 0.8, "justify": "LM", "font": f"8c,{font}"} fig = pygmt.Figure() fig.basemap( From afe3be6f4e2b5d5b5980389acc3eaaecd6d80948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 7 Nov 2025 21:29:25 +0100 Subject: [PATCH 217/379] Adjust position of vertical wordmark --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4ded27f8bdd..782450d7b31 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -89,7 +89,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no font = "AvantGarde-Book" match wordmark: case "vertical": - args_text_wm = {"x": 0, "y": -5, "justify": "CT", "font": f"2.5c,{font}"} + args_text_wm = {"x": 0, "y": -4.5, "justify": "CT", "font": f"2.5c,{font}"} case True | "horizontal": args_text_wm = {"x": 4.5, "y": 0.8, "justify": "LM", "font": f"8c,{font}"} From 736e60f582cb55534a2af80f954d9f99997eb5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 7 Nov 2025 21:58:21 +0100 Subject: [PATCH 218/379] Adjust position of wordmark --- pygmt/src/pygmtlogo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 782450d7b31..cf88ed72ac8 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -80,16 +80,18 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no symbol = "c" # circle diameter = r0 + r1 diameter_add = r0 - r1 + y_wm = -4.5 # for vertical orientation of wordmark case "hexagon": symbol = "h" # hexagon diameter = 8.6 diameter_add = 0.6 + y_wm = -5 # Define wordmark font = "AvantGarde-Book" match wordmark: case "vertical": - args_text_wm = {"x": 0, "y": -4.5, "justify": "CT", "font": f"2.5c,{font}"} + args_text_wm = {"x": 0, "y": y_wm, "justify": "CT", "font": f"2.5c,{font}"} case True | "horizontal": args_text_wm = {"x": 4.5, "y": 0.8, "justify": "LM", "font": f"8c,{font}"} From 0d8b9310c0a20357a586a81781bc0c2d1cf44fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 7 Nov 2025 23:31:30 +0100 Subject: [PATCH 219/379] Fit hexagon into circles --- pygmt/src/pygmtlogo.py | 87 +++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index cf88ed72ac8..1dbb75b77e8 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -44,12 +44,12 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no r0, r1, r2, r3, r4, r5 = size * np.array( [1.0, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] ) - thick = r0 - r1 # Thick pen in cm - thin = thick / 3.0 # Thin pen in cm + thick = r0 - r1 # thick pen in centimeters + thin = thick / 3.0 # thin pen in centimeters # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True - perspective = "30+w0/0" # Rotation around the center by 30 degrees ccw + perspective = "30+w0/0" # by 30 degrees ccw # Define colors color_light = "white" @@ -78,20 +78,24 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no match shape: case "circle": symbol = "c" # circle - diameter = r0 + r1 - diameter_add = r0 - r1 - y_wm = -4.5 # for vertical orientation of wordmark + size_shape = r0 + r1 # radius + size_shape_add = r0 - r1 + hex_factor = 1 + y_vertline = r0 + y_arrow = -r0 case "hexagon": symbol = "h" # hexagon - diameter = 8.6 - diameter_add = 0.6 - y_wm = -5 + size_shape = (r0 - 0.3) * 2 # diameter + size_shape_add = 0.6 + hex_factor = 0.98 + y_vertline = r1 * 0.99 + y_arrow = -r1 * 0.99 # Define wordmark font = "AvantGarde-Book" match wordmark: case "vertical": - args_text_wm = {"x": 0, "y": y_wm, "justify": "CT", "font": f"2.5c,{font}"} + args_text_wm = {"x": 0, "y": -4.5, "justify": "CT", "font": f"2.5c,{font}"} case True | "horizontal": args_text_wm = {"x": 4.5, "y": 0.8, "justify": "LM", "font": f"8c,{font}"} @@ -103,24 +107,23 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no frame="+n", ) - # Blue circle / hexagon for Earth - fig.plot( - x=0, - y=0, - style=f"{symbol}{diameter}c", - pen=f"{thick}c,{blue}", - fill=color_bg, - perspective=True, - no_clip=True, # needed for corners of hexagon shape - ) - # fig.show() + # White filled circle / hexagon for Earth + args_shape = { + "x": 0, + "y": 0, + "style": f"{symbol}{size_shape}c", + "perspective": True, + "no_clip": True, # needed for corners of hexagon shape + } + fig.plot(fill=color_bg, **args_shape) + fig.show() # Compass (plot vertical line on top of letters G and M again at the end) x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 lines_compass = [ - ([-r0, -r3], [0, 0]), # horizontal lines + ([-r0 * hex_factor, -r3], [0, 0]), # horizontal lines ([-r5, 0], [0, 0]), - ([r3, r0], [0, 0]), + ([r3, r0 * hex_factor], [0, 0]), ([0, 0], [-r3, 0]), # vertical line ([-x1, -x2], [x1, x2]), # upper left ([-x1, -x2], [-x1, -x2]), # lower left @@ -129,7 +132,11 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ] for x, y in lines_compass: fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) - # fig.show() + fig.show() + + # Blue outlined circle / hexagon for Earth + fig.plot(pen=f"{thick}c,{blue}", **args_shape) + fig.show() # Letter G angles = np.deg2rad(np.arange(90, 361, 1.0)) @@ -144,15 +151,17 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ] ) fig.plot(x=x, y=y, fill=red, perspective=True) - # fig.show() + fig.show() # Upper vertical red line # Space between red line and blue circle / hexagon - fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick * 1.5}c,{color_bg}", perspective=True) - # fig.show() + fig.plot( + x=[0, 0], y=[y_vertline, r3], pen=f"{thick * 1.5}c,{color_bg}", perspective=True + ) + fig.show() # red line - fig.plot(x=[0, 0], y=[r0, r3], pen=f"{thick}c,{red}", perspective=True) - # fig.show() + fig.plot(x=[0, 0], y=[y_vertline, r3], pen=f"{thick}c,{red}", perspective=True) + fig.show() # Letter M # Polygon with small distance to horizontal line of letter G @@ -191,7 +200,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no m_y2 - m_y2 / 3, # left pick below ] fig.plot(x=m_x, y=m_y, close=True, fill=red, perspective=True) - # fig.show() + fig.show() # Letter T # Red curved horizontal line @@ -201,44 +210,44 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no # Ensure the same X coordinate for the right edge of T and the middle of M. mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2.0) fig.plot(x=t_x[mask], y=t_y[mask], fill=red, perspective=True) - # fig.show() + fig.show() # The arrow fig.plot( - data=[[0, -r2, 0, -r0 * 1.05]], + data=[[0, -r2, 0, y_arrow * 1.05]], pen=color_bg, style=f"v{thick * 1.6}c+s+e+h0+a60+g{color_bg}", perspective=True, ) - # fig.show() + fig.show() fig.plot( - data=[[0, -r3, 0, -r0]], + data=[[0, -r3, 0, y_arrow]], pen=f"{thick}c,{red}", style=f"v{thick * 1.4}c+s+e+h0+a60+g{red}", perspective=True, ) - # fig.show() + fig.show() # Extra vertical compass line above letters G and M. fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"5p,{yellow}", perspective=True) - # fig.show() + fig.show() # 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}{diameter + diameter_add}c", + style=f"{symbol}{size_shape + size_shape_add}c", pen=f"1p,{color_dark}", perspective=True, no_clip=True, ) - # fig.show() + fig.show() # Add wordmark "PyGMT" if wordmark: text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" fig.text(text=text_wm, no_clip=True, **args_text_wm) - # fig.show() + fig.show() # Helpful for implementing the logo; not included in the logo # Circles for the different radii From fd934802701cc1e941297fada010b24466a39b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 8 Nov 2025 00:29:45 +0100 Subject: [PATCH 220/379] Correct horizontal compass line to be on top of Earth out line --- pygmt/src/pygmtlogo.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 1dbb75b77e8..9d79595f644 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -107,7 +107,6 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no frame="+n", ) - # White filled circle / hexagon for Earth args_shape = { "x": 0, "y": 0, @@ -115,6 +114,7 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no "perspective": True, "no_clip": True, # needed for corners of hexagon shape } + # White filled circle / hexagon for Earth fig.plot(fill=color_bg, **args_shape) fig.show() @@ -130,13 +130,18 @@ def create_logo(color=True, theme="light", shape="circle", wordmark=True): # no ([x1, x2 + (r4 - r5)], [x1, x2 + (r4 - r5)]), # upper right ([x1, x2], [-x1, -x2]), # lower right ] - for x, y in lines_compass: + # Non-horizontal compass lines + for x, y in lines_compass[4 : len(lines_compass)]: fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) fig.show() # Blue outlined circle / hexagon for Earth fig.plot(pen=f"{thick}c,{blue}", **args_shape) fig.show() + # Horizontal compass lines + for x, y in lines_compass[0:4]: + fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) + fig.show() # Letter G angles = np.deg2rad(np.arange(90, 361, 1.0)) From 5e8bd7e34958ec253b8e242ec1087824ca0a5c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 8 Nov 2025 10:08:23 +0100 Subject: [PATCH 221/379] Reorder parameters in function definition Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 9d79595f644..6175c112963 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -10,7 +10,12 @@ import pygmt -def create_logo(color=True, theme="light", shape="circle", wordmark=True): # noqa: PLR0915 +def create_logo( + shape : Literal["circle", "hexagon"] = "circle", + theme : Literal["light", "dark"] = "light", + wordmark : Literal["horizontal", "vertical"] | bool = True, + color : bool = True, + ): # noqa: PLR0915 """ Create the PyGMT logo using PyGMT. The design of the logo is kindly provided by `@sfrooti `_ From c8be1686a65c4b1e82c4311daf51a0f1fd2338e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 8 Nov 2025 10:09:06 +0100 Subject: [PATCH 222/379] Reorder docstrings Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6175c112963..16607a10760 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -24,20 +24,21 @@ def create_logo( Parameters ---------- - color : bool - Set to ``True`` to use colors referring to Python (blue and yellow) and GMT - (red) [Default]. For ``False``, the logo is drawn in black and white. - theme : str + 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 [gray20] background). - shape : str - Shape of the visual. Use ``"circle"`` for a circle shape [Default] or - ``"hexagon"`` for a hexagon shape. - wordmark : bool, str + wordmark Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and ``False`` to add no wordmark. + color + Set to ``True`` to use colors referring to Python (blue and yellow) and GMT + (red) [Default]. For ``False``, the logo is drawn in black and white. + """ # Helpful definitions From fdbca4ac09d1ef7172379bfc26f7e83a569953fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 9 Nov 2025 14:12:59 +0100 Subject: [PATCH 223/379] Import typing --- pygmt/src/pygmtlogo.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 16607a10760..245d5fd6e0d 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -5,17 +5,18 @@ """ from pathlib import Path +from typing import Literal import numpy as np import pygmt def create_logo( - shape : Literal["circle", "hexagon"] = "circle", - theme : Literal["light", "dark"] = "light", - wordmark : Literal["horizontal", "vertical"] | bool = True, - color : bool = True, - ): # noqa: PLR0915 + shape: Literal["circle", "hexagon"] = "circle", + theme: Literal["light", "dark"] = "light", + wordmark: Literal["horizontal", "vertical"] | bool = True, + color: bool = True, +): """ Create the PyGMT logo using PyGMT. The design of the logo is kindly provided by `@sfrooti `_ From 8a79a38b44136545ec8f6fb57ef39a311016322c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 10 Nov 2025 09:50:45 +0100 Subject: [PATCH 224/379] Un-commend fig.show --- pygmt/src/pygmtlogo.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 245d5fd6e0d..77de2fe9768 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -123,7 +123,7 @@ def create_logo( } # White filled circle / hexagon for Earth fig.plot(fill=color_bg, **args_shape) - fig.show() + # fig.show() # Compass (plot vertical line on top of letters G and M again at the end) x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 @@ -140,15 +140,15 @@ def create_logo( # Non-horizontal compass lines for x, y in lines_compass[4 : len(lines_compass)]: fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) - fig.show() + # fig.show() # Blue outlined circle / hexagon for Earth fig.plot(pen=f"{thick}c,{blue}", **args_shape) - fig.show() + # fig.show() # Horizontal compass lines for x, y in lines_compass[0:4]: fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) - fig.show() + # fig.show() # Letter G angles = np.deg2rad(np.arange(90, 361, 1.0)) @@ -163,17 +163,17 @@ def create_logo( ] ) fig.plot(x=x, y=y, fill=red, perspective=True) - fig.show() + # fig.show() # Upper vertical red line # Space between red line and blue circle / hexagon fig.plot( x=[0, 0], y=[y_vertline, r3], pen=f"{thick * 1.5}c,{color_bg}", perspective=True ) - fig.show() + # fig.show() # red line fig.plot(x=[0, 0], y=[y_vertline, r3], pen=f"{thick}c,{red}", perspective=True) - fig.show() + # fig.show() # Letter M # Polygon with small distance to horizontal line of letter G @@ -212,7 +212,7 @@ def create_logo( m_y2 - m_y2 / 3, # left pick below ] fig.plot(x=m_x, y=m_y, close=True, fill=red, perspective=True) - fig.show() + # fig.show() # Letter T # Red curved horizontal line @@ -222,7 +222,7 @@ def create_logo( # Ensure the same X coordinate for the right edge of T and the middle of M. mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2.0) fig.plot(x=t_x[mask], y=t_y[mask], fill=red, perspective=True) - fig.show() + # fig.show() # The arrow fig.plot( data=[[0, -r2, 0, y_arrow * 1.05]], @@ -230,18 +230,18 @@ def create_logo( style=f"v{thick * 1.6}c+s+e+h0+a60+g{color_bg}", perspective=True, ) - fig.show() + # fig.show() fig.plot( data=[[0, -r3, 0, y_arrow]], pen=f"{thick}c,{red}", style=f"v{thick * 1.4}c+s+e+h0+a60+g{red}", perspective=True, ) - fig.show() + # fig.show() # Extra vertical compass line above letters G and M. fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"5p,{yellow}", perspective=True) - fig.show() + # fig.show() # Outline around the shape for black and white color with dark theme if not color and theme == "dark": @@ -253,13 +253,13 @@ def create_logo( perspective=True, no_clip=True, ) - fig.show() + # fig.show() # Add wordmark "PyGMT" if wordmark: text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" fig.text(text=text_wm, no_clip=True, **args_text_wm) - fig.show() + # fig.show() # Helpful for implementing the logo; not included in the logo # Circles for the different radii From 26c6dcea23889b45f7e9c3e55651181d410a18a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 15 Nov 2025 17:55:13 +0100 Subject: [PATCH 225/379] Use line length --- pygmt/src/pygmtlogo.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 77de2fe9768..179cb1e927c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -108,10 +108,7 @@ def create_logo( fig = pygmt.Figure() fig.basemap( - region=region, - projection=projection, - perspective=perspective, - frame="+n", + region=region, projection=projection, perspective=perspective, frame="+n" ) args_shape = { From efba97a1d0a63e81a024b77957ef8ef7237dfc4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 18 Nov 2025 22:51:49 +0100 Subject: [PATCH 226/379] Polish --- pygmt/src/pygmtlogo.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 179cb1e927c..01a90d49cc5 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -49,14 +49,14 @@ def create_logo( # Radii r0, r1, r2, r3, r4, r5 = size * np.array( - [1.0, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] + [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] ) thick = r0 - r1 # thick pen in centimeters - thin = thick / 3.0 # thin pen in centimeters + thin = thick / 3 # thin pen in centimeters # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True - perspective = "30+w0/0" # by 30 degrees ccw + perspective = "30+w0/0" # by 30 degrees counter-clockwise # Define colors color_light = "white" @@ -148,14 +148,14 @@ def create_logo( # fig.show() # Letter G - angles = np.deg2rad(np.arange(90, 361, 1.0)) + angles = np.deg2rad(np.arange(90, 361, 1)) x = np.concatenate( [np.cos(angles) * r4, [r4, 0, 0, r5], np.cos(np.flip(angles)) * r5] ) y = np.concatenate( [ np.sin(angles) * r4, - [(r4 - r5) / 2.0, (r4 - r5) / 2.0, -(r4 - r5) / 2.0, -(r4 - r5) / 2.0], + [(r4 - r5) / 2, (r4 - r5) / 2, -(r4 - r5) / 2, -(r4 - r5) / 2], np.sin(np.flip(angles)) * r5, ] ) @@ -176,7 +176,7 @@ def create_logo( # Polygon with small distance to horizontal line of letter G # Starting point: lower right corner of the left vertical line of letter M # Direction: clockwise - m_x1 = thin / 2.0 # Half of the pen thickness of compass lines. + m_x1 = thin / 2 # half of the pen thickness of compass lines. m_x2 = r4 m_x = [ m_x1 + m_x2 / 5, # vertical left upwards @@ -192,7 +192,7 @@ def create_logo( m_x1 + (m_x2 - m_x1) / 2, # mid pick below m_x1 + m_x2 / 5, # left pick below ] - m_y1 = (r4 - r5) / 2.0 * 1.2 + m_y1 = (r4 - r5) / 2 * 1.2 m_y2 = r4 m_y = [ m_y1, # vertical left upwards @@ -217,7 +217,7 @@ def create_logo( t_x = np.concatenate([r3 * np.sin(angles), r2 * np.sin(np.flip(angles))]) t_y = np.concatenate([r3 * np.cos(angles), r2 * np.cos(np.flip(angles))]) # Ensure the same X coordinate for the right edge of T and the middle of M. - mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2.0) + mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2) fig.plot(x=t_x[mask], y=t_y[mask], fill=red, perspective=True) # fig.show() # The arrow From e0b61c83dd81177d5e03c88bdb66f65636abb196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 19 Nov 2025 21:05:48 +0100 Subject: [PATCH 227/379] Update comment --- pygmt/src/pygmtlogo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 01a90d49cc5..84ecee7a6b6 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -116,7 +116,7 @@ def create_logo( "y": 0, "style": f"{symbol}{size_shape}c", "perspective": True, - "no_clip": True, # needed for corners of hexagon shape + "no_clip": True, # Needed for corners of hexagon shape } # White filled circle / hexagon for Earth fig.plot(fill=color_bg, **args_shape) @@ -176,7 +176,7 @@ def create_logo( # Polygon with small distance to horizontal line of letter G # Starting point: lower right corner of the left vertical line of letter M # Direction: clockwise - m_x1 = thin / 2 # half of the pen thickness of compass lines. + m_x1 = thin / 2 # Half of the pen thickness of compass lines. m_x2 = r4 m_x = [ m_x1 + m_x2 / 5, # vertical left upwards @@ -279,8 +279,8 @@ def pygmtlogo( # noqa: PLR0913 theme="light", shape="circle", wordmark=True, - position=None, # -> use position parameter of Figure.image - box=None, # -> use box parameter of Figure.image + position=None, # -> Use position parameter of Figure.image + box=None, # -> Use box parameter of Figure.image projection=None, region=None, verbose=None, From 64f6c9a00ffb4db85971686068dda4e44c70e1d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 21 Nov 2025 20:48:50 +0100 Subject: [PATCH 228/379] Do not invert wordmark text in gray20, always use gray20 --- pygmt/src/pygmtlogo.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 84ecee7a6b6..0cd276a1bf7 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -70,16 +70,28 @@ def create_logo( if theme == "dark": blue = yellow = red = color_light - # Background and wordmark + # Background match theme: case "light": color_bg = color_light - color_py = blue - color_gmt = color_dark + # color_py = blue + # color_gmt = color_dark case "dark": color_bg = color_dark - color_py = yellow - color_gmt = color_light + # color_py = yellow + # color_gmt = color_light + + # Wordmark + # color_text_gmt = color_dark # red + # if not color: + # color_text_gmt = color_dark + color_text_py = color_dark + if color: + match theme: + case "light": + color_text_py = blue + case "dark": + color_text_py = yellow # Define shape match shape: @@ -254,7 +266,7 @@ def create_logo( # Add wordmark "PyGMT" if wordmark: - text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" + text_wm = f"@;{color_text_py};Py@;;@;{color_dark};GMT@;;" fig.text(text=text_wm, no_clip=True, **args_text_wm) # fig.show() From bb31966b6304e44c2e7d00ebd788882c1c414c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 21 Nov 2025 21:14:52 +0100 Subject: [PATCH 229/379] Revert "Do not invert wordmark text in gray20, always use gray20" This reverts commit 64f6c9a00ffb4db85971686068dda4e44c70e1d4. --- pygmt/src/pygmtlogo.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 0cd276a1bf7..84ecee7a6b6 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -70,28 +70,16 @@ def create_logo( if theme == "dark": blue = yellow = red = color_light - # Background + # Background and wordmark match theme: case "light": color_bg = color_light - # color_py = blue - # color_gmt = color_dark + color_py = blue + color_gmt = color_dark case "dark": color_bg = color_dark - # color_py = yellow - # color_gmt = color_light - - # Wordmark - # color_text_gmt = color_dark # red - # if not color: - # color_text_gmt = color_dark - color_text_py = color_dark - if color: - match theme: - case "light": - color_text_py = blue - case "dark": - color_text_py = yellow + color_py = yellow + color_gmt = color_light # Define shape match shape: @@ -266,7 +254,7 @@ def create_logo( # Add wordmark "PyGMT" if wordmark: - text_wm = f"@;{color_text_py};Py@;;@;{color_dark};GMT@;;" + text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" fig.text(text=text_wm, no_clip=True, **args_text_wm) # fig.show() From 8b1fd3433f978f99e4470e518b73390d33cb0c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 21 Nov 2025 21:17:41 +0100 Subject: [PATCH 230/379] Reduce examples --- examples/gallery/embellishments/pygmt_logo.py | 80 +------------------ 1 file changed, 1 insertion(+), 79 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 3773537f4e2..855f52d57dc 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -10,84 +10,6 @@ dark mode. The wordmark can be added at the right side or bottom of the visual. """ -import pygmt - -fig = pygmt.Figure() -fig.pygmtlogo() -fig.show() - -# %% - -fig = pygmt.Figure() -fig.pygmtlogo(theme="dark", box="+ggray20") -fig.show() - -# %% - -fig = pygmt.Figure() -fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=[1, "+gtan"]) - -fig.pygmtlogo(position="jTL+o0.2c+w4c", box="+gwhite+p1p,gray") -fig.pygmtlogo(shape="hexagon", position="jTR+o0.2c+w4c") - -fig.pygmtlogo(color=False, wordmark=False, position="jTL+o0.5c/2c+w1.5c", box=False) -fig.pygmtlogo( - color=False, - theme="dark", - shape="hexagon", - wordmark=False, - position="jTR+o0.5c/2c+w1.5c", - box=False, -) -fig.pygmtlogo(wordmark="vertical", position="jMC+w2c", box="+gwhite") - -fig.show() - -# %% -# All combinations - -i_plot = 0 - -fig = pygmt.Figure() - -for color in [True, False]: - for theme in ["light", "dark"]: - for shape in ["circle", "hexagon"]: - for wordmark in [False, True, "horizontal", "vertical"]: - for box in [False, True]: - if not box: - box_used = False - elif box: - if theme == "light": - box_used = "+gwhite" - elif theme == "dark": - box_used = "+ggray20" - # fig = pygmt.Figure() - fig.basemap( - region=[-1, 1, -1, 1], projection="X2.5c/3.5c", frame="+gtan" - ) - # fig.image("@needle.png", position="jMC+w2c", box=box_used) - fig.pygmtlogo( - color=color, - theme=theme, - shape=shape, - wordmark=wordmark, - position="jMC+w2c", - box=box_used, - ) - - fig.shift_origin(xshift="+w+0.5c") - n_hor = 8 - if i_plot in range(n_hor - 1, 100, n_hor): - fig.shift_origin( - xshift=f"-{(n_hor * 2.5 + n_hor * 0.5)}c", - yshift="-h-0.5c", - ) # n_hor*width + n_hor*xshift - - i_plot = i_plot + 1 -fig.show() - - # %% # All versions # modified from @@ -157,4 +79,4 @@ fig.show(width=1000) -# sphinx_gallery_thumbnail_number = 3 +# sphinx_gallery_thumbnail_number = 1 From f88f30f7f3252b3edc80901c7533546bfb58062f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 21 Nov 2025 21:19:49 +0100 Subject: [PATCH 231/379] Uncomment fig.show --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 84ecee7a6b6..dc21a53ad9f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -266,7 +266,7 @@ def create_logo( with pygmt.config(MAP_FRAME_TYPE="inside"): fig.basemap(frame="a1g1") - fig.show() + # fig.show() fig_name_logo = "pygmt_logo" fig.savefig(fname=f"{fig_name_logo}.eps") From b2384794a1efc5223eebcc047e765338fe627e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 21 Nov 2025 21:33:46 +0100 Subject: [PATCH 232/379] Not help gridlines --- pygmt/src/pygmtlogo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index dc21a53ad9f..98c01cb7f50 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -260,11 +260,11 @@ def create_logo( # Helpful for implementing the logo; not included in the logo # Circles for the different radii - for r in [r0, r1, r2, r3, r4, r5, r2 + (r3 - r4)]: - fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") + # for r in [r0, r1, r2, r3, r4, r5, r2 + (r3 - r4)]: + # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") # Map frame with annotations, tick marks, and gridlines - with pygmt.config(MAP_FRAME_TYPE="inside"): - fig.basemap(frame="a1g1") + # with pygmt.config(MAP_FRAME_TYPE="inside"): + # fig.basemap(frame="a1g1") # fig.show() fig_name_logo = "pygmt_logo" From 93c8ff584232d4211e7e3701f43cd849d4d8370c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 21 Nov 2025 21:34:09 +0100 Subject: [PATCH 233/379] Adjust background color in example --- examples/gallery/embellishments/pygmt_logo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index 855f52d57dc..c02d75b105c 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -19,7 +19,7 @@ fig = pygmt.Figure() # Logo without workmark. -fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame=["a1f1g1", "+gtan"]) +fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame=["a1f1g1", "+ggray50"]) for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: for color, shape in [ (True, "circle"), @@ -39,7 +39,7 @@ fig.shift_origin(xshift=8) # Logo with vertical wordmark. -fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame=["a1f1g1", "+gtan"]) +fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame=["a1f1g1", "+ggray50"]) for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: for color, shape in [ (True, "circle"), @@ -59,7 +59,7 @@ fig.shift_origin(xshift=8) # Logo with horizontal wordmark. -fig.basemap(region=[0, 20, 0, 13], projection="x1c", frame=["a1f1g1", "+gtan"]) +fig.basemap(region=[0, 20, 0, 13], projection="x1c", frame=["a1f1g1", "+ggray50"]) for x, y, theme in [(1, 3, "light"), (11, 3, "dark")]: for color, shape in [ (True, "circle"), From abc89a61fd7814e48f14e2be352e7d61e67914a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 5 Feb 2026 17:54:30 +0100 Subject: [PATCH 234/379] Exclude PLR0915 --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 98c01cb7f50..ec415866f1c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -11,7 +11,7 @@ import pygmt -def create_logo( +def create_logo( # noqa: PLR0915 shape: Literal["circle", "hexagon"] = "circle", theme: Literal["light", "dark"] = "light", wordmark: Literal["horizontal", "vertical"] | bool = True, From 27937b5ecee1dfcbe4ff16fb18f2d73f8b478997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 5 Feb 2026 17:55:28 +0100 Subject: [PATCH 235/379] Add pygmt import --- examples/gallery/embellishments/pygmt_logo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index c02d75b105c..e288b175471 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -11,11 +11,12 @@ """ # %% +import pygmt + # All versions # modified from # https://github.com/GenericMappingTools/pygmt/pull/3849#issuecomment-2753372170 # by @seisman - fig = pygmt.Figure() # Logo without workmark. From aad7292fb75444101140b5e6108395e3e8cca007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 1 Apr 2026 12:27:48 +0200 Subject: [PATCH 236/379] Adjust line length --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index ec415866f1c..d96005d8ca8 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -34,8 +34,8 @@ def create_logo( # noqa: PLR0915 wordmark Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the - visual [Default]. Use ``"vertical"`` to place the wordmark below the visual - and ``False`` to add no wordmark. + visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and + ``False`` to add no wordmark. color Set to ``True`` to use colors referring to Python (blue and yellow) and GMT (red) [Default]. For ``False``, the logo is drawn in black and white. From 194b15d4fb24c52caf7b7820fd272ab661172784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 1 Apr 2026 12:29:34 +0200 Subject: [PATCH 237/379] Use new pythonic code for no frame --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d96005d8ca8..6fee233669a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -108,7 +108,7 @@ def create_logo( # noqa: PLR0915 fig = pygmt.Figure() fig.basemap( - region=region, projection=projection, perspective=perspective, frame="+n" + region=region, projection=projection, perspective=perspective, frame="none" ) args_shape = { From 12005a71a7ae93374c683d1cf66033da8a3d7326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 13 Apr 2026 22:40:58 +0200 Subject: [PATCH 238/379] Define private functions for letter coordinates --- pygmt/src/pygmtlogo.py | 118 ++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 50 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6fee233669a..98fe45117ec 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -106,6 +106,69 @@ def create_logo( # noqa: PLR0915 case True | "horizontal": args_text_wm = {"x": 4.5, "y": 0.8, "justify": "LM", "font": f"8c,{font}"} + # Private functions for letter coordinates + # Letter G + def letter_g_coords(): + angles = np.deg2rad(np.arange(90, 361, 1)) + g_x = np.concatenate( + [np.cos(angles) * r4, [r4, 0, 0, r5], np.cos(np.flip(angles)) * r5] + ) + g_y = np.concatenate( + [ + np.sin(angles) * r4, + [(r4 - r5) / 2, (r4 - r5) / 2, -(r4 - r5) / 2, -(r4 - r5) / 2], + np.sin(np.flip(angles)) * r5, + ] + ) + return g_x, g_y + + # Letter M + def letter_m_coords(): + m_x1 = thin / 2 # Half of the pen thickness of compass lines. + m_x2 = r4 + m_x = [ + m_x1 + m_x2 / 5, # vertical left upwards + m_x1, + m_x1, + m_x1 + m_x2 / 5, + m_x1 + (m_x2 - m_x1) / 2, # mid pick above + m_x2 - m_x2 / 5, # vertical right downwards + m_x2, + m_x2, + m_x2 - m_x2 / 5, + m_x2 - m_x2 / 5, # right pick below + m_x1 + (m_x2 - m_x1) / 2, # mid pick below + m_x1 + m_x2 / 5, # left pick below + ] + m_y1 = (r4 - r5) / 2 * 1.2 + m_y2 = r4 + m_y = [ + m_y1, # vertical left upwards + m_y1, + m_y2, + m_y2, + m_y2 - m_y2 / 4, # mid pick above + m_y2, # vertical right downwards + m_y2, + m_y1, + m_y1, + m_y2 - m_y2 / 3, # right pick below + m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below + m_y2 - m_y2 / 3, # left pick below + ] + return m_x, m_y, m_x1, m_x2 + + # Letter T + def letter_t_coords(): + angles = np.deg2rad(np.arange(150, 210, 0.1)) + t_x = np.concatenate([r3 * np.sin(angles), r2 * np.sin(np.flip(angles))]) + t_y = np.concatenate([r3 * np.cos(angles), r2 * np.cos(np.flip(angles))]) + # Ensure the same X coordinate for the right edge of T and the middle of M. + mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2) + t_x = t_x[mask] + t_y = t_y[mask] + return t_x, t_y + fig = pygmt.Figure() fig.basemap( region=region, projection=projection, perspective=perspective, frame="none" @@ -148,18 +211,8 @@ def create_logo( # noqa: PLR0915 # fig.show() # Letter G - angles = np.deg2rad(np.arange(90, 361, 1)) - x = np.concatenate( - [np.cos(angles) * r4, [r4, 0, 0, r5], np.cos(np.flip(angles)) * r5] - ) - y = np.concatenate( - [ - np.sin(angles) * r4, - [(r4 - r5) / 2, (r4 - r5) / 2, -(r4 - r5) / 2, -(r4 - r5) / 2], - np.sin(np.flip(angles)) * r5, - ] - ) - fig.plot(x=x, y=y, fill=red, perspective=True) + x_g, y_g = letter_g_coords() + fig.plot(x=x_g, y=y_g, fill=red, perspective=True) # fig.show() # Upper vertical red line @@ -176,49 +229,14 @@ def create_logo( # noqa: PLR0915 # Polygon with small distance to horizontal line of letter G # Starting point: lower right corner of the left vertical line of letter M # Direction: clockwise - m_x1 = thin / 2 # Half of the pen thickness of compass lines. - m_x2 = r4 - m_x = [ - m_x1 + m_x2 / 5, # vertical left upwards - m_x1, - m_x1, - m_x1 + m_x2 / 5, - m_x1 + (m_x2 - m_x1) / 2, # mid pick above - m_x2 - m_x2 / 5, # vertical right downwards - m_x2, - m_x2, - m_x2 - m_x2 / 5, - m_x2 - m_x2 / 5, # right pick below - m_x1 + (m_x2 - m_x1) / 2, # mid pick below - m_x1 + m_x2 / 5, # left pick below - ] - m_y1 = (r4 - r5) / 2 * 1.2 - m_y2 = r4 - m_y = [ - m_y1, # vertical left upwards - m_y1, - m_y2, - m_y2, - m_y2 - m_y2 / 4, # mid pick above - m_y2, # vertical right downwards - m_y2, - m_y1, - m_y1, - m_y2 - m_y2 / 3, # right pick below - m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below - m_y2 - m_y2 / 3, # left pick below - ] + m_x, m_y, m_x1, m_x2 = letter_m_coords() fig.plot(x=m_x, y=m_y, close=True, fill=red, perspective=True) # fig.show() # Letter T # Red curved horizontal line - angles = np.deg2rad(np.arange(150, 210, 0.1)) - t_x = np.concatenate([r3 * np.sin(angles), r2 * np.sin(np.flip(angles))]) - t_y = np.concatenate([r3 * np.cos(angles), r2 * np.cos(np.flip(angles))]) - # Ensure the same X coordinate for the right edge of T and the middle of M. - mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2) - fig.plot(x=t_x[mask], y=t_y[mask], fill=red, perspective=True) + t_x, t_y = letter_t_coords() + fig.plot(x=t_x, y=t_y, fill=red, perspective=True) # fig.show() # The arrow fig.plot( From a585464f77def387b0d1be7234ef21a47da50101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 14 Apr 2026 10:20:17 +0200 Subject: [PATCH 239/379] Make private function --- pygmt/src/pygmtlogo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 98fe45117ec..f6b5a79b5ff 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -108,7 +108,7 @@ def create_logo( # noqa: PLR0915 # Private functions for letter coordinates # Letter G - def letter_g_coords(): + def _letter_g_coords(): angles = np.deg2rad(np.arange(90, 361, 1)) g_x = np.concatenate( [np.cos(angles) * r4, [r4, 0, 0, r5], np.cos(np.flip(angles)) * r5] @@ -123,7 +123,7 @@ def letter_g_coords(): return g_x, g_y # Letter M - def letter_m_coords(): + def _letter_m_coords(): m_x1 = thin / 2 # Half of the pen thickness of compass lines. m_x2 = r4 m_x = [ @@ -159,7 +159,7 @@ def letter_m_coords(): return m_x, m_y, m_x1, m_x2 # Letter T - def letter_t_coords(): + def _letter_t_coords(): angles = np.deg2rad(np.arange(150, 210, 0.1)) t_x = np.concatenate([r3 * np.sin(angles), r2 * np.sin(np.flip(angles))]) t_y = np.concatenate([r3 * np.cos(angles), r2 * np.cos(np.flip(angles))]) From 01f7c6951a6d85bb5f94a43571bdcb74807f7430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 14 Apr 2026 10:20:48 +0200 Subject: [PATCH 240/379] Add comment --- pygmt/src/pygmtlogo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index f6b5a79b5ff..c4e40285311 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -160,6 +160,7 @@ def _letter_m_coords(): # Letter T def _letter_t_coords(): + # Red curved horizontal line angles = np.deg2rad(np.arange(150, 210, 0.1)) t_x = np.concatenate([r3 * np.sin(angles), r2 * np.sin(np.flip(angles))]) t_y = np.concatenate([r3 * np.cos(angles), r2 * np.cos(np.flip(angles))]) From 5da7271870e0a2ad0eba7247fa7eadadb6047127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 14 Apr 2026 10:26:42 +0200 Subject: [PATCH 241/379] Fix --- pygmt/src/pygmtlogo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index c4e40285311..ec01f22811d 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -212,7 +212,7 @@ def _letter_t_coords(): # fig.show() # Letter G - x_g, y_g = letter_g_coords() + x_g, y_g = _letter_g_coords() fig.plot(x=x_g, y=y_g, fill=red, perspective=True) # fig.show() @@ -230,13 +230,13 @@ def _letter_t_coords(): # Polygon with small distance to horizontal line of letter G # Starting point: lower right corner of the left vertical line of letter M # Direction: clockwise - m_x, m_y, m_x1, m_x2 = letter_m_coords() + m_x, m_y, m_x1, m_x2 = _letter_m_coords() fig.plot(x=m_x, y=m_y, close=True, fill=red, perspective=True) # fig.show() # Letter T # Red curved horizontal line - t_x, t_y = letter_t_coords() + t_x, t_y = _letter_t_coords() fig.plot(x=t_x, y=t_y, fill=red, perspective=True) # fig.show() # The arrow From adfd925f050a39b8c2dcb5124fd86efbf98a50e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 14 Apr 2026 11:12:10 +0200 Subject: [PATCH 242/379] Use easier to understand code for letter G --- pygmt/src/pygmtlogo.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index ec01f22811d..e8b461309fa 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -109,17 +109,24 @@ def create_logo( # noqa: PLR0915 # Private functions for letter coordinates # Letter G def _letter_g_coords(): - angles = np.deg2rad(np.arange(90, 361, 1)) - g_x = np.concatenate( - [np.cos(angles) * r4, [r4, 0, 0, r5], np.cos(np.flip(angles)) * r5] - ) - g_y = np.concatenate( - [ - np.sin(angles) * r4, - [(r4 - r5) / 2, (r4 - r5) / 2, -(r4 - r5) / 2, -(r4 - r5) / 2], - np.sin(np.flip(angles)) * r5, - ] - ) + outer_angles = np.deg2rad(np.arange(90, 361)) + inner_angles = outer_angles[::-1] + offset = (r4 - r5) / 2 + + # Outer arc (r4) + arc_outer_x = np.cos(outer_angles) * r4 + arc_outer_y = np.sin(outer_angles) * r4 + + # Connecting lines + connector_x = [r4, 0, 0, r5] + connector_y = [offset, offset, -offset, -offset] + + # Inner arc (r5) + arc_inner_x = np.cos(inner_angles) * r5 + arc_inner_y = np.sin(inner_angles) * r5 + + 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 g_x, g_y # Letter M From 625a1ff2bbc85eddd9d81a6a00b1a1b14b5cb84c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:21:23 +0200 Subject: [PATCH 243/379] Use shorter way to set maximum length Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e8b461309fa..9e62e994ed2 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -206,7 +206,7 @@ def _letter_t_coords(): ([x1, x2], [-x1, -x2]), # lower right ] # Non-horizontal compass lines - for x, y in lines_compass[4 : len(lines_compass)]: + for x, y in lines_compass[4:]: fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) # fig.show() From a44dc64c8db14398633c25923c0d9f98b850587d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:22:09 +0200 Subject: [PATCH 244/379] Use shorter way to set zero as start Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 9e62e994ed2..07001ed2cad 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -214,7 +214,7 @@ def _letter_t_coords(): fig.plot(pen=f"{thick}c,{blue}", **args_shape) # fig.show() # Horizontal compass lines - for x, y in lines_compass[0:4]: + for x, y in lines_compass[:4]: fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) # fig.show() From 0a006bbb5d255e309f61e019c1674e96684375ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:23:10 +0200 Subject: [PATCH 245/379] Remove close=True Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 07001ed2cad..36ce3bb5469 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -238,7 +238,7 @@ def _letter_t_coords(): # Starting point: lower right corner of the left vertical line of letter M # Direction: clockwise m_x, m_y, m_x1, m_x2 = _letter_m_coords() - fig.plot(x=m_x, y=m_y, close=True, fill=red, perspective=True) + fig.plot(x=m_x, y=m_y, fill=red, perspective=True) # fig.show() # Letter T From 31955c63ee2d0840ee7c6464ab77f0cf6da494fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 16 Apr 2026 18:24:39 +0200 Subject: [PATCH 246/379] Use more compact definition of letter G Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 36ce3bb5469..cd46475f7c3 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -112,19 +112,13 @@ def _letter_g_coords(): outer_angles = np.deg2rad(np.arange(90, 361)) inner_angles = outer_angles[::-1] offset = (r4 - r5) / 2 - # Outer arc (r4) - arc_outer_x = np.cos(outer_angles) * r4 - arc_outer_y = np.sin(outer_angles) * r4 - + arc_outer_x, arc_outer_y = np.cos(outer_angles) * r4, np.sin(outer_angles) * r4 # Connecting lines - connector_x = [r4, 0, 0, r5] - connector_y = [offset, offset, -offset, -offset] - + connector_x, connector_y = [r4, 0, 0, r5], [offset, offset, -offset, -offset] # Inner arc (r5) - arc_inner_x = np.cos(inner_angles) * r5 - arc_inner_y = np.sin(inner_angles) * 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 g_x, g_y From da0a5efcd15e8b34882a7c1b2735e4834ceb90ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 16 Apr 2026 18:26:47 +0200 Subject: [PATCH 247/379] Make coordinate calculation for curved top line of letter T clearer Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index cd46475f7c3..e50baed7f37 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -159,17 +159,15 @@ def _letter_m_coords(): ] return m_x, m_y, m_x1, m_x2 - # Letter T + # Letter T: curved horizontal line for the top of T def _letter_t_coords(): - # Red curved horizontal line - angles = np.deg2rad(np.arange(150, 210, 0.1)) - t_x = np.concatenate([r3 * np.sin(angles), r2 * np.sin(np.flip(angles))]) - t_y = np.concatenate([r3 * np.cos(angles), r2 * np.cos(np.flip(angles))]) + outer_angles = np.deg2rad(np.arange(150, 210)) + inner_angles = outer_angles[::-1] + t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) + t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) # Ensure the same X coordinate for the right edge of T and the middle of M. mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2) - t_x = t_x[mask] - t_y = t_y[mask] - return t_x, t_y + return t_x[mask], t_y[mask] fig = pygmt.Figure() fig.basemap( From cada956edd18f17c82339215348708a54fac13ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 17 Apr 2026 23:39:04 +0200 Subject: [PATCH 248/379] Add name for private function for letter G Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e50baed7f37..6fe30f201a9 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -106,9 +106,8 @@ def create_logo( # noqa: PLR0915 case True | "horizontal": args_text_wm = {"x": 4.5, "y": 0.8, "justify": "LM", "font": f"8c,{font}"} - # Private functions for letter coordinates - # Letter G def _letter_g_coords(): + """Coordinates for letter G.""" outer_angles = np.deg2rad(np.arange(90, 361)) inner_angles = outer_angles[::-1] offset = (r4 - r5) / 2 From 46f3cbf821a89ca55ae898062505ac3a38a4c71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 17 Apr 2026 23:39:44 +0200 Subject: [PATCH 249/379] Add name for private function for letter T Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6fe30f201a9..d0a2450506e 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -160,6 +160,7 @@ def _letter_m_coords(): # Letter T: curved horizontal line for the top of T def _letter_t_coords(): + """Coordinates of the top curved horizontal line for letter T.""" outer_angles = np.deg2rad(np.arange(150, 210)) inner_angles = outer_angles[::-1] t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) From 3e6c4ba06fb09cc46e798c3a134f87936467666e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 17 Apr 2026 23:40:15 +0200 Subject: [PATCH 250/379] Add name for private function for letter M Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d0a2450506e..f93fcfd6aab 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -122,8 +122,8 @@ def _letter_g_coords(): g_y = np.concatenate([arc_outer_y, connector_y, arc_inner_y]) return g_x, g_y - # Letter M def _letter_m_coords(): + """Coordinates for letter M.""" m_x1 = thin / 2 # Half of the pen thickness of compass lines. m_x2 = r4 m_x = [ From 9257aaec0fb7f7caa6836448947e755382dc9f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 17 Apr 2026 23:40:52 +0200 Subject: [PATCH 251/379] Combine comment lines Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index f93fcfd6aab..94d4486343e 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -233,8 +233,7 @@ def _letter_t_coords(): fig.plot(x=m_x, y=m_y, fill=red, perspective=True) # fig.show() - # Letter T - # Red curved horizontal line + # Letter T: red curved horizontal line t_x, t_y = _letter_t_coords() fig.plot(x=t_x, y=t_y, fill=red, perspective=True) # fig.show() From e6c21bdbd28c2a417ffe5d4b725cabe205bc67f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 17 Apr 2026 23:42:00 +0200 Subject: [PATCH 252/379] Make compass line consisten with the defined thicknesses Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 94d4486343e..d0e32d3b299 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -254,7 +254,7 @@ def _letter_t_coords(): # fig.show() # Extra vertical compass line above letters G and M. - fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"5p,{yellow}", perspective=True) + fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"{thin}c,{yellow}", perspective=True) # fig.show() # Outline around the shape for black and white color with dark theme From e9f6594bb88d66e5cacd14c27dddecf3ea4b99a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 17:44:47 +0200 Subject: [PATCH 253/379] Remove comment --- pygmt/src/pygmtlogo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d0e32d3b299..25cef45c57a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -158,7 +158,6 @@ def _letter_m_coords(): ] return m_x, m_y, m_x1, m_x2 - # Letter T: curved horizontal line for the top of T def _letter_t_coords(): """Coordinates of the top curved horizontal line for letter T.""" outer_angles = np.deg2rad(np.arange(150, 210)) From b9a262db8b23be46e76aecc4b761d195bae8160b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 17:51:54 +0200 Subject: [PATCH 254/379] Add private function for compass lines --- pygmt/src/pygmtlogo.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 25cef45c57a..c1dbd989a4f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -168,6 +168,21 @@ def _letter_t_coords(): mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2) return t_x[mask], t_y[mask] + def _compass_lines(): + """Compass (plot vertical line on top of letters G and M again at the end).""" + x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 + compass_lines = [ + ([-r0 * hex_factor, -r3], [0, 0]), # horizontal lines + ([-r5, 0], [0, 0]), + ([r3, r0 * hex_factor], [0, 0]), + ([0, 0], [-r3, 0]), # vertical line + ([-x1, -x2], [x1, x2]), # upper left + ([-x1, -x2], [-x1, -x2]), # lower left + ([x1, x2 + (r4 - r5)], [x1, x2 + (r4 - r5)]), # upper right + ([x1, x2], [-x1, -x2]), # lower right + ] + return compass_lines + fig = pygmt.Figure() fig.basemap( region=region, projection=projection, perspective=perspective, frame="none" @@ -184,20 +199,9 @@ def _letter_t_coords(): fig.plot(fill=color_bg, **args_shape) # fig.show() - # Compass (plot vertical line on top of letters G and M again at the end) - x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 - lines_compass = [ - ([-r0 * hex_factor, -r3], [0, 0]), # horizontal lines - ([-r5, 0], [0, 0]), - ([r3, r0 * hex_factor], [0, 0]), - ([0, 0], [-r3, 0]), # vertical line - ([-x1, -x2], [x1, x2]), # upper left - ([-x1, -x2], [-x1, -x2]), # lower left - ([x1, x2 + (r4 - r5)], [x1, x2 + (r4 - r5)]), # upper right - ([x1, x2], [-x1, -x2]), # lower right - ] + compass_lines = _compass_lines() # Non-horizontal compass lines - for x, y in lines_compass[4:]: + for x, y in compass_lines[4:]: fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) # fig.show() @@ -205,7 +209,7 @@ def _letter_t_coords(): fig.plot(pen=f"{thick}c,{blue}", **args_shape) # fig.show() # Horizontal compass lines - for x, y in lines_compass[:4]: + for x, y in compass_lines[:4]: fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) # fig.show() From f226cacfc7a141dfff79e9c0b70ddfa0e9cbf57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 17:52:19 +0200 Subject: [PATCH 255/379] Fix indent --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index c1dbd989a4f..c957af8cfbc 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -159,7 +159,7 @@ def _letter_m_coords(): return m_x, m_y, m_x1, m_x2 def _letter_t_coords(): - """Coordinates of the top curved horizontal line for letter T.""" + """Coordinates of the top curved horizontal line for letter T.""" outer_angles = np.deg2rad(np.arange(150, 210)) inner_angles = outer_angles[::-1] t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) From 28e055b325c788588016b11ca3d6556ba06bfb96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 17:59:17 +0200 Subject: [PATCH 256/379] Define private function for vertical red line --- pygmt/src/pygmtlogo.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index c957af8cfbc..6c4b6729d55 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -88,14 +88,14 @@ def create_logo( # noqa: PLR0915 size_shape = r0 + r1 # radius size_shape_add = r0 - r1 hex_factor = 1 - y_vertline = r0 + y_vline = r0 y_arrow = -r0 case "hexagon": symbol = "h" # hexagon size_shape = (r0 - 0.3) * 2 # diameter size_shape_add = 0.6 hex_factor = 0.98 - y_vertline = r1 * 0.99 + y_vline = r1 * 0.99 y_arrow = -r1 * 0.99 # Define wordmark @@ -183,6 +183,12 @@ def _compass_lines(): ] return compass_lines + # Upper vertical red line + def _red_line_coords(): + red_line_x = [0, 0] + red_line_y = [y_vline, r3] + return red_line_y, red_line_x + fig = pygmt.Figure() fig.basemap( region=region, projection=projection, perspective=perspective, frame="none" @@ -220,12 +226,13 @@ def _compass_lines(): # Upper vertical red line # Space between red line and blue circle / hexagon + red_line_x, red_line_y = _red_line_coords() fig.plot( - x=[0, 0], y=[y_vertline, r3], pen=f"{thick * 1.5}c,{color_bg}", perspective=True + x=red_line_x, y=red_line_y, pen=f"{thick * 1.5}c,{color_bg}", perspective=True ) # fig.show() # red line - fig.plot(x=[0, 0], y=[y_vertline, r3], pen=f"{thick}c,{red}", perspective=True) + fig.plot(x=red_line_x, y=red_line_y, pen=f"{thick}c,{red}", perspective=True) # fig.show() # Letter M From 2f9289918208d8d360ea28ed9ae4f38ee6d9d9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 17:59:54 +0200 Subject: [PATCH 257/379] Make variable names consistent --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6c4b6729d55..d74020061d6 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -220,8 +220,8 @@ def _red_line_coords(): # fig.show() # Letter G - x_g, y_g = _letter_g_coords() - fig.plot(x=x_g, y=y_g, fill=red, perspective=True) + g_x, g_y = _letter_g_coords() + fig.plot(x=g_x, y=g_y, fill=red, perspective=True) # fig.show() # Upper vertical red line From 832d8367b26e4b0c6e56dbce1550a9938c614ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 18:01:52 +0200 Subject: [PATCH 258/379] Make variable names consistent --- pygmt/src/pygmtlogo.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d74020061d6..6cd71b3b085 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -88,15 +88,15 @@ def create_logo( # noqa: PLR0915 size_shape = r0 + r1 # radius size_shape_add = r0 - r1 hex_factor = 1 - y_vline = r0 - y_arrow = -r0 + vline_y = r0 + arrow_y = -r0 case "hexagon": symbol = "h" # hexagon size_shape = (r0 - 0.3) * 2 # diameter size_shape_add = 0.6 hex_factor = 0.98 - y_vline = r1 * 0.99 - y_arrow = -r1 * 0.99 + vline_y = r1 * 0.99 + arrow_y = -r1 * 0.99 # Define wordmark font = "AvantGarde-Book" @@ -186,7 +186,7 @@ def _compass_lines(): # Upper vertical red line def _red_line_coords(): red_line_x = [0, 0] - red_line_y = [y_vline, r3] + red_line_y = [vline_y, r3] return red_line_y, red_line_x fig = pygmt.Figure() @@ -249,14 +249,14 @@ def _red_line_coords(): # fig.show() # The arrow fig.plot( - data=[[0, -r2, 0, y_arrow * 1.05]], + data=[[0, -r2, 0, arrow_y * 1.05]], pen=color_bg, style=f"v{thick * 1.6}c+s+e+h0+a60+g{color_bg}", perspective=True, ) # fig.show() fig.plot( - data=[[0, -r3, 0, y_arrow]], + data=[[0, -r3, 0, arrow_y]], pen=f"{thick}c,{red}", style=f"v{thick * 1.4}c+s+e+h0+a60+g{red}", perspective=True, From 346c6558550caaebfa44665fd0d85258b279054e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 18:04:47 +0200 Subject: [PATCH 259/379] Add and improve private function names --- pygmt/src/pygmtlogo.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6cd71b3b085..d93a730933c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -169,7 +169,10 @@ def _letter_t_coords(): return t_x[mask], t_y[mask] def _compass_lines(): - """Compass (plot vertical line on top of letters G and M again at the end).""" + """ + Coordinates of compass lines. + Plot vertical line on top of letters G and M again at the end. + """ x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 compass_lines = [ ([-r0 * hex_factor, -r3], [0, 0]), # horizontal lines @@ -183,8 +186,8 @@ def _compass_lines(): ] return compass_lines - # Upper vertical red line def _red_line_coords(): + """Coordinates of Upper vertical red line.""" red_line_x = [0, 0] red_line_y = [vline_y, r3] return red_line_y, red_line_x From a57bb5c815ca04711ee5d3ae7b3a36090ee96f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 18:05:52 +0200 Subject: [PATCH 260/379] Remove unneeded comments --- pygmt/src/pygmtlogo.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d93a730933c..8590dd33535 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -239,9 +239,6 @@ def _red_line_coords(): # fig.show() # Letter M - # Polygon with small distance to horizontal line of letter G - # Starting point: lower right corner of the left vertical line of letter M - # Direction: clockwise m_x, m_y, m_x1, m_x2 = _letter_m_coords() fig.plot(x=m_x, y=m_y, fill=red, perspective=True) # fig.show() From 23b63865bba430681ca18a1336686e41a80da4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 18:20:26 +0200 Subject: [PATCH 261/379] Move docs to plot function --- pygmt/src/pygmtlogo.py | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 8590dd33535..2b774480e8f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -21,25 +21,6 @@ def create_logo( # noqa: PLR0915 Create the PyGMT logo using PyGMT. The design of the logo is kindly provided by `@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 [gray20] background). - wordmark - Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set - to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the - visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and - ``False`` to add no wordmark. - color - Set to ``True`` to use colors referring to Python (blue and yellow) and GMT - (red) [Default]. For ``False``, the logo is drawn in black and white. - """ # Helpful definitions @@ -316,6 +297,26 @@ def pygmtlogo( # noqa: PLR0913 ): """ Plot the PyGMT logo. + The design of the logo is kindly provided by `@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 [gray20] background). + wordmark + Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set + to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the + visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and + ``False`` to add no wordmark. + color + Set to ``True`` to use colors referring to Python (blue and yellow) and GMT + (red) [Default]. For ``False``, the logo is drawn in black and white. """ # ----------------------------------------------------------------------------- From e3d6e0cf2f9893f6add5b81c5800cb800cbe628c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 18:43:38 +0200 Subject: [PATCH 262/379] Fix mixed return onf red line coordinates --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 2b774480e8f..3b01bb1fbd1 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -171,7 +171,7 @@ def _red_line_coords(): """Coordinates of Upper vertical red line.""" red_line_x = [0, 0] red_line_y = [vline_y, r3] - return red_line_y, red_line_x + return red_line_x, red_line_y fig = pygmt.Figure() fig.basemap( From 1bb046b772f72dacfb9eb7726485cfadde1058d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 18 Apr 2026 20:44:37 +0200 Subject: [PATCH 263/379] Fix typo --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 3b01bb1fbd1..2fe06adbf8b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -168,7 +168,7 @@ def _compass_lines(): return compass_lines def _red_line_coords(): - """Coordinates of Upper vertical red line.""" + """Coordinates of upper vertical red line.""" red_line_x = [0, 0] red_line_y = [vline_y, r3] return red_line_x, red_line_y From 24c876094bef5884d29ed3122a3389660d16c851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 19 Apr 2026 10:04:26 +0200 Subject: [PATCH 264/379] Improve coordinates of letter M MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 2fe06adbf8b..b3f6202e7be 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -121,21 +121,21 @@ def _letter_m_coords(): m_x1 + (m_x2 - m_x1) / 2, # mid pick below m_x1 + m_x2 / 5, # left pick below ] - m_y1 = (r4 - r5) / 2 * 1.2 + m_y1 = (r4 - r5) / 2 * 1.25 # horizontal gab between the letters G and M m_y2 = r4 m_y = [ m_y1, # vertical left upwards m_y1, m_y2, m_y2, - m_y2 - m_y2 / 4, # mid pick above + r5, #m_y2 - m_y2 / 4, # mid pick above m_y2, # vertical right downwards m_y2, m_y1, m_y1, - m_y2 - m_y2 / 3, # right pick below - m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below - m_y2 - m_y2 / 3, # left pick below + r5, #m_y2 - m_y2 / 3, # right pick below + r5 - (r4 - r5), #m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below + r5, #m_y2 - m_y2 / 3, # left pick below ] return m_x, m_y, m_x1, m_x2 From 44ba9856fa97975c21e2b8835f1f7f332f106be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 19 Apr 2026 10:06:00 +0200 Subject: [PATCH 265/379] Introduce a third pen thickness for letters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index b3f6202e7be..ccff70123e3 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -32,8 +32,10 @@ def create_logo( # noqa: PLR0915 r0, r1, r2, r3, r4, r5 = size * np.array( [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] ) - thick = r0 - r1 # thick pen in centimeters - thin = thick / 3 # thin pen in centimeters + # Pen thicknesses + thick = r0 - r1 # for shape + middle = r4 - r5 # for letters + thin = thick / 3 # for compass lines # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True @@ -216,7 +218,7 @@ def _red_line_coords(): ) # fig.show() # red line - fig.plot(x=red_line_x, y=red_line_y, pen=f"{thick}c,{red}", perspective=True) + fig.plot(x=red_line_x, y=red_line_y, pen=f"{middle}c,{red}", perspective=True) # fig.show() # Letter M @@ -232,13 +234,13 @@ def _red_line_coords(): fig.plot( data=[[0, -r2, 0, arrow_y * 1.05]], pen=color_bg, - style=f"v{thick * 1.6}c+s+e+h0+a60+g{color_bg}", + style=f"v{thick * 1.45}c+s+e+h0+a60+g{color_bg}", perspective=True, ) # fig.show() fig.plot( data=[[0, -r3, 0, arrow_y]], - pen=f"{thick}c,{red}", + pen=f"{middle}c,{red}", style=f"v{thick * 1.4}c+s+e+h0+a60+g{red}", perspective=True, ) From 70f67840fa7199caf829baefee0d4b7373af60fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 19 Apr 2026 10:08:30 +0200 Subject: [PATCH 266/379] Return dicts by private functions Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 678 ++++++++++++++++++++--------------------- 1 file changed, 338 insertions(+), 340 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index ccff70123e3..4d18e2f172b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -1,345 +1,343 @@ -""" -pygmtlogo - Create and plot the PyGMT logo. -The design of the logo is kindly provided by `@sfrooti `_ -and consists of a visual and the wordmark "PyGMT". -""" - -from pathlib import Path -from typing import Literal - -import numpy as np -import pygmt - - -def create_logo( # noqa: PLR0915 - shape: Literal["circle", "hexagon"] = "circle", - theme: Literal["light", "dark"] = "light", - wordmark: Literal["horizontal", "vertical"] | bool = True, - color: bool = True, -): - """ - Create the PyGMT logo using PyGMT. - The design of the logo is kindly provided by `@sfrooti `_ - and consists of a visual and the wordmark "PyGMT". - """ - - # Helpful definitions - size = 4 - region = [-size, size] * 2 - projection = "x1c" - - # Radii - r0, r1, r2, r3, r4, r5 = size * np.array( - [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] - ) +""" +pygmtlogo - Create and plot the PyGMT logo. +The design of the logo is kindly provided by `@sfrooti `_ +and consists of a visual and the wordmark "PyGMT". +""" + +from pathlib import Path +from typing import Literal + +import numpy as np +import pygmt + + +def create_logo( # noqa: PLR0915 + shape: Literal["circle", "hexagon"] = "circle", + theme: Literal["light", "dark"] = "light", + wordmark: Literal["horizontal", "vertical"] | bool = True, + color: bool = True, +): + """ + Create the PyGMT logo using PyGMT. + The design of the logo is kindly provided by `@sfrooti `_ + and consists of a visual and the wordmark "PyGMT". + """ + + # Helpful definitions + size = 4 + region = [-size, size] * 2 + projection = "x1c" + + # Radii + r0, r1, r2, r3, r4, r5 = size * np.array( + [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] + ) # Pen thicknesses thick = r0 - r1 # for shape middle = r4 - r5 # for letters thin = thick / 3 # for compass lines - - # Rotation around z (vertical) axis placed in the center - # Has to be applied to each plotting command, up on second call set to True - perspective = "30+w0/0" # by 30 degrees counter-clockwise - - # 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" # circle - size_shape = r0 + r1 # radius - size_shape_add = r0 - r1 - hex_factor = 1 - vline_y = r0 - arrow_y = -r0 - case "hexagon": - symbol = "h" # hexagon - size_shape = (r0 - 0.3) * 2 # diameter - size_shape_add = 0.6 - hex_factor = 0.98 - vline_y = r1 * 0.99 - arrow_y = -r1 * 0.99 - - # 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 True | "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 = (r4 - r5) / 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 g_x, g_y - - def _letter_m_coords(): - """Coordinates for letter M.""" - m_x1 = thin / 2 # Half of the pen thickness of compass lines. - m_x2 = r4 - m_x = [ - m_x1 + m_x2 / 5, # vertical left upwards - m_x1, - m_x1, - m_x1 + m_x2 / 5, - m_x1 + (m_x2 - m_x1) / 2, # mid pick above - m_x2 - m_x2 / 5, # vertical right downwards - m_x2, - m_x2, - m_x2 - m_x2 / 5, - m_x2 - m_x2 / 5, # right pick below - m_x1 + (m_x2 - m_x1) / 2, # mid pick below - m_x1 + m_x2 / 5, # left pick below - ] - m_y1 = (r4 - r5) / 2 * 1.25 # horizontal gab between the letters G and M - m_y2 = r4 - m_y = [ - m_y1, # vertical left upwards - m_y1, - m_y2, - m_y2, - r5, #m_y2 - m_y2 / 4, # mid pick above - m_y2, # vertical right downwards - m_y2, - m_y1, - m_y1, - r5, #m_y2 - m_y2 / 3, # right pick below - r5 - (r4 - r5), #m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below - r5, #m_y2 - m_y2 / 3, # left pick below - ] - return m_x, m_y, m_x1, m_x2 - - def _letter_t_coords(): - """Coordinates of the top curved horizontal line for letter T.""" - outer_angles = np.deg2rad(np.arange(150, 210)) - inner_angles = outer_angles[::-1] - t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) - t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) - # Ensure the same X coordinate for the right edge of T and the middle of M. - mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2) - return t_x[mask], t_y[mask] - - def _compass_lines(): - """ - Coordinates of compass lines. - Plot vertical line on top of letters G and M again at the end. - """ - x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 - compass_lines = [ - ([-r0 * hex_factor, -r3], [0, 0]), # horizontal lines - ([-r5, 0], [0, 0]), - ([r3, r0 * hex_factor], [0, 0]), - ([0, 0], [-r3, 0]), # vertical line - ([-x1, -x2], [x1, x2]), # upper left - ([-x1, -x2], [-x1, -x2]), # lower left - ([x1, x2 + (r4 - r5)], [x1, x2 + (r4 - r5)]), # upper right - ([x1, x2], [-x1, -x2]), # lower right - ] - return compass_lines - - def _red_line_coords(): - """Coordinates of upper vertical red line.""" - red_line_x = [0, 0] - red_line_y = [vline_y, r3] - return red_line_x, red_line_y - - fig = pygmt.Figure() - fig.basemap( - region=region, projection=projection, perspective=perspective, frame="none" - ) - - args_shape = { - "x": 0, - "y": 0, - "style": f"{symbol}{size_shape}c", - "perspective": True, - "no_clip": True, # Needed for corners of hexagon shape - } - # White filled circle / hexagon for Earth - fig.plot(fill=color_bg, **args_shape) - # fig.show() - - compass_lines = _compass_lines() - # Non-horizontal compass lines - for x, y in compass_lines[4:]: - fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) - # fig.show() - - # Blue outlined circle / hexagon for Earth - fig.plot(pen=f"{thick}c,{blue}", **args_shape) - # fig.show() - # Horizontal compass lines - for x, y in compass_lines[:4]: - fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) - # fig.show() - - # Letter G - g_x, g_y = _letter_g_coords() - fig.plot(x=g_x, y=g_y, fill=red, perspective=True) - # fig.show() - - # Upper vertical red line - # Space between red line and blue circle / hexagon - red_line_x, red_line_y = _red_line_coords() - fig.plot( - x=red_line_x, y=red_line_y, pen=f"{thick * 1.5}c,{color_bg}", perspective=True - ) - # fig.show() - # red line - fig.plot(x=red_line_x, y=red_line_y, pen=f"{middle}c,{red}", perspective=True) - # fig.show() - - # Letter M - m_x, m_y, m_x1, m_x2 = _letter_m_coords() - fig.plot(x=m_x, y=m_y, fill=red, perspective=True) - # fig.show() - - # Letter T: red curved horizontal line - t_x, t_y = _letter_t_coords() - fig.plot(x=t_x, y=t_y, fill=red, perspective=True) - # fig.show() - # The arrow - fig.plot( - data=[[0, -r2, 0, arrow_y * 1.05]], - pen=color_bg, - style=f"v{thick * 1.45}c+s+e+h0+a60+g{color_bg}", - perspective=True, - ) - # fig.show() - fig.plot( - data=[[0, -r3, 0, arrow_y]], + + # Rotation around z (vertical) axis placed in the center + # Has to be applied to each plotting command, up on second call set to True + perspective = "30+w0/0" # by 30 degrees counter-clockwise + + # 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" # circle + size_shape = r0 + r1 # radius + size_shape_add = r0 - r1 + hex_factor = 1 + vline_y = r0 + arrow_y = -r0 + case "hexagon": + symbol = "h" # hexagon + size_shape = (r0 - 0.3) * 2 # diameter + size_shape_add = 0.6 + hex_factor = 0.98 + vline_y = r1 * 0.99 + arrow_y = -r1 * 0.99 + + # 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 True | "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 = (r4 - r5) / 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.""" + m_x1 = thin / 2 # Half of the pen thickness of compass lines. + m_x2 = r4 + m_x = [ + m_x1 + m_x2 / 5, # vertical left upwards + m_x1, + m_x1, + m_x1 + m_x2 / 5, + m_x1 + (m_x2 - m_x1) / 2, # mid pick above + m_x2 - m_x2 / 5, # vertical right downwards + m_x2, + m_x2, + m_x2 - m_x2 / 5, + m_x2 - m_x2 / 5, # right pick below + m_x1 + (m_x2 - m_x1) / 2, # mid pick below + m_x1 + m_x2 / 5, # left pick below + ] + m_y1 = (r4 - r5) / 2 * 1.25 # horizontal gab between the letters G and M + m_y2 = r4 + m_y = [ + m_y1, # vertical left upwards + m_y1, + m_y2, + m_y2, + r5, #m_y2 - m_y2 / 4, # mid pick above + m_y2, # vertical right downwards + m_y2, + m_y1, + m_y1, + r5, #m_y2 - m_y2 / 3, # right pick below + r5 - (r4 - r5), #m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below + r5, #m_y2 - m_y2 / 3, # left pick below + ] + return m_x, m_y, m_x1, m_x2 + + def _letter_t_coords(): + """Coordinates of the top curved horizontal line for letter T.""" + outer_angles = np.deg2rad(np.arange(150, 210)) + inner_angles = outer_angles[::-1] + t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) + t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) + # Ensure the same X coordinate for the right edge of T and the middle of M. + mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2) + return {"x": t_x[mask], "y": t_y[mask]} + + def _compass_lines(): + """ + Coordinates of compass lines. + Plot vertical line on top of letters G and M again at the end. + """ + x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 + compass_lines = [ + ([-r0 * hex_factor, -r3], [0, 0]), # horizontal lines + ([-r5, 0], [0, 0]), + ([r3, r0 * hex_factor], [0, 0]), + ([0, 0], [-r3, 0]), # vertical line + ([-x1, -x2], [x1, x2]), # upper left + ([-x1, -x2], [-x1, -x2]), # lower left + ([x1, x2 + (r4 - r5)], [x1, x2 + (r4 - r5)]), # upper right + ([x1, x2], [-x1, -x2]), # lower right + ] + return compass_lines + + def _red_line_coords(): + """Coordinates of upper vertical red line.""" + red_line_x = [0, 0] + red_line_y = [vline_y, r3] + return red_line_x, red_line_y + + fig = pygmt.Figure() + fig.basemap( + region=region, projection=projection, perspective=perspective, frame="none" + ) + + args_shape = { + "x": 0, + "y": 0, + "style": f"{symbol}{size_shape}c", + "perspective": True, + "no_clip": True, # Needed for corners of hexagon shape + } + # White filled circle / hexagon for Earth + fig.plot(fill=color_bg, **args_shape) + # fig.show() + + compass_lines = _compass_lines() + # Non-horizontal compass lines + for x, y in compass_lines[4:]: + fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) + # fig.show() + + # Blue outlined circle / hexagon for Earth + fig.plot(pen=f"{thick}c,{blue}", **args_shape) + # fig.show() + # Horizontal compass lines + for x, y in compass_lines[:4]: + fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) + # fig.show() + + # Letter G + fig.plot(data=_letter_g_coords(), fill=red, perspective=True) + # fig.show() + + # Upper vertical red line + # Space between red line and blue circle / hexagon + red_line_x, red_line_y = _red_line_coords() + fig.plot( + x=red_line_x, y=red_line_y, pen=f"{thick * 1.5}c,{color_bg}", perspective=True + ) + # fig.show() + # red line + fig.plot(x=red_line_x, y=red_line_y, pen=f"{middle}c,{red}", perspective=True) + # fig.show() + + # Letter M + m_x, m_y, m_x1, m_x2 = _letter_m_coords() + fig.plot(x=m_x, y=m_y, fill=red, perspective=True) + # fig.show() + + # Letter T: red curved horizontal line + fig.plot(data=_letter_t_coords(), fill=red, perspective=True) + # fig.show() + # The arrow + fig.plot( + data=[[0, -r2, 0, arrow_y * 1.05]], + pen=color_bg, + style=f"v{thick * 1.45}c+s+e+h0+a60+g{color_bg}", + perspective=True, + ) + # fig.show() + fig.plot( + data=[[0, -r3, 0, arrow_y]], pen=f"{middle}c,{red}", - style=f"v{thick * 1.4}c+s+e+h0+a60+g{red}", - perspective=True, - ) - # fig.show() - - # Extra vertical compass line above letters G and M. - fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"{thin}c,{yellow}", perspective=True) - # fig.show() - - # 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 + size_shape_add}c", - pen=f"1p,{color_dark}", - perspective=True, - no_clip=True, - ) - # fig.show() - - # Add wordmark "PyGMT" - if wordmark: - text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" - fig.text(text=text_wm, no_clip=True, **args_text_wm) - # fig.show() - - # Helpful for implementing the logo; not included in the logo - # Circles for the different radii - # for r in [r0, r1, r2, r3, r4, r5, r2 + (r3 - r4)]: - # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") - # Map frame with annotations, tick marks, and gridlines - # with pygmt.config(MAP_FRAME_TYPE="inside"): - # fig.basemap(frame="a1g1") - - # fig.show() - fig_name_logo = "pygmt_logo" - fig.savefig(fname=f"{fig_name_logo}.eps") - - return fig_name_logo - - -def pygmtlogo( # noqa: PLR0913 - self, - color=True, - theme="light", - shape="circle", - wordmark=True, - position=None, # -> Use position parameter of Figure.image - box=None, # -> Use box parameter of Figure.image - projection=None, - region=None, - verbose=None, - panel=None, - transparency=None, -): - """ - Plot the PyGMT logo. - The design of the logo is kindly provided by `@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 [gray20] background). - wordmark - Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set - to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the - visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and - ``False`` to add no wordmark. - color - Set to ``True`` to use colors referring to Python (blue and yellow) and GMT - (red) [Default]. For ``False``, the logo is drawn in black and white. - """ - - # ----------------------------------------------------------------------------- - # Create logo file - # ----------------------------------------------------------------------------- - fig_name_logo = create_logo( - color=color, theme=theme, shape=shape, wordmark=wordmark - ) - - # ----------------------------------------------------------------------------- - # Add to existing Figure instance - # ----------------------------------------------------------------------------- - self.image( - imagefile=f"{fig_name_logo}.eps", - position=position, - box=box, - projection=projection, - region=region, - verbose=verbose, - panel=panel, - transparency=transparency, - ) - - Path.unlink(f"{fig_name_logo}.eps") + style=f"v{thick * 1.4}c+s+e+h0+a60+g{red}", + perspective=True, + ) + # fig.show() + + # Extra vertical compass line above letters G and M. + fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"{thin}c,{yellow}", perspective=True) + # fig.show() + + # 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 + size_shape_add}c", + pen=f"1p,{color_dark}", + perspective=True, + no_clip=True, + ) + # fig.show() + + # Add wordmark "PyGMT" + if wordmark: + text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" + fig.text(text=text_wm, no_clip=True, **args_text_wm) + # fig.show() + + # Helpful for implementing the logo; not included in the logo + # Circles for the different radii + # for r in [r0, r1, r2, r3, r4, r5, r2 + (r3 - r4)]: + # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") + # Map frame with annotations, tick marks, and gridlines + # with pygmt.config(MAP_FRAME_TYPE="inside"): + # fig.basemap(frame="a1g1") + + # fig.show() + fig_name_logo = "pygmt_logo" + fig.savefig(fname=f"{fig_name_logo}.eps") + + return fig_name_logo + + +def pygmtlogo( # noqa: PLR0913 + self, + color=True, + theme="light", + shape="circle", + wordmark=True, + position=None, # -> Use position parameter of Figure.image + box=None, # -> Use box parameter of Figure.image + projection=None, + region=None, + verbose=None, + panel=None, + transparency=None, +): + """ + Plot the PyGMT logo. + The design of the logo is kindly provided by `@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 [gray20] background). + wordmark + Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set + to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the + visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and + ``False`` to add no wordmark. + color + Set to ``True`` to use colors referring to Python (blue and yellow) and GMT + (red) [Default]. For ``False``, the logo is drawn in black and white. + """ + + # ----------------------------------------------------------------------------- + # Create logo file + # ----------------------------------------------------------------------------- + fig_name_logo = create_logo( + color=color, theme=theme, shape=shape, wordmark=wordmark + ) + + # ----------------------------------------------------------------------------- + # Add to existing Figure instance + # ----------------------------------------------------------------------------- + self.image( + imagefile=f"{fig_name_logo}.eps", + position=position, + box=box, + projection=projection, + region=region, + verbose=verbose, + panel=panel, + transparency=transparency, + ) + + Path.unlink(f"{fig_name_logo}.eps") From adc2d78c68cb7ad5316e74785d7c7eb5806f2c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 10:12:20 +0200 Subject: [PATCH 267/379] Introduce third pen thickness for letters --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4d18e2f172b..0bfa1981728 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -213,7 +213,7 @@ def _red_line_coords(): # Space between red line and blue circle / hexagon red_line_x, red_line_y = _red_line_coords() fig.plot( - x=red_line_x, y=red_line_y, pen=f"{thick * 1.5}c,{color_bg}", perspective=True + x=red_line_x, y=red_line_y, pen=f"{middle * 1.45}c,{color_bg}", perspective=True ) # fig.show() # red line From e730197ecf69840db66758bd04a4ea28307fc6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 10:13:26 +0200 Subject: [PATCH 268/379] Add blank lines to improved readability of the code --- pygmt/src/pygmtlogo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 0bfa1981728..8b485996c2c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -200,6 +200,7 @@ def _red_line_coords(): # Blue outlined circle / hexagon for Earth fig.plot(pen=f"{thick}c,{blue}", **args_shape) # fig.show() + # Horizontal compass lines for x, y in compass_lines[:4]: fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) @@ -228,6 +229,7 @@ def _red_line_coords(): # Letter T: red curved horizontal line fig.plot(data=_letter_t_coords(), fill=red, perspective=True) # fig.show() + # The arrow fig.plot( data=[[0, -r2, 0, arrow_y * 1.05]], From 979050c5da6b3c25d60d7513a1bbf0dc7eec6f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 10:16:10 +0200 Subject: [PATCH 269/379] Change thick to thicker and middle to thick --- pygmt/src/pygmtlogo.py | 690 ++++++++++++++++++++--------------------- 1 file changed, 345 insertions(+), 345 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 8b485996c2c..f985067993b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -1,345 +1,345 @@ -""" -pygmtlogo - Create and plot the PyGMT logo. -The design of the logo is kindly provided by `@sfrooti `_ -and consists of a visual and the wordmark "PyGMT". -""" - -from pathlib import Path -from typing import Literal - -import numpy as np -import pygmt - - -def create_logo( # noqa: PLR0915 - shape: Literal["circle", "hexagon"] = "circle", - theme: Literal["light", "dark"] = "light", - wordmark: Literal["horizontal", "vertical"] | bool = True, - color: bool = True, -): - """ - Create the PyGMT logo using PyGMT. - The design of the logo is kindly provided by `@sfrooti `_ - and consists of a visual and the wordmark "PyGMT". - """ - - # Helpful definitions - size = 4 - region = [-size, size] * 2 - projection = "x1c" - - # Radii - r0, r1, r2, r3, r4, r5 = size * np.array( - [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] - ) - # Pen thicknesses - thick = r0 - r1 # for shape - middle = r4 - r5 # for letters - thin = thick / 3 # for compass lines - - # Rotation around z (vertical) axis placed in the center - # Has to be applied to each plotting command, up on second call set to True - perspective = "30+w0/0" # by 30 degrees counter-clockwise - - # 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" # circle - size_shape = r0 + r1 # radius - size_shape_add = r0 - r1 - hex_factor = 1 - vline_y = r0 - arrow_y = -r0 - case "hexagon": - symbol = "h" # hexagon - size_shape = (r0 - 0.3) * 2 # diameter - size_shape_add = 0.6 - hex_factor = 0.98 - vline_y = r1 * 0.99 - arrow_y = -r1 * 0.99 - - # 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 True | "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 = (r4 - r5) / 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.""" - m_x1 = thin / 2 # Half of the pen thickness of compass lines. - m_x2 = r4 - m_x = [ - m_x1 + m_x2 / 5, # vertical left upwards - m_x1, - m_x1, - m_x1 + m_x2 / 5, - m_x1 + (m_x2 - m_x1) / 2, # mid pick above - m_x2 - m_x2 / 5, # vertical right downwards - m_x2, - m_x2, - m_x2 - m_x2 / 5, - m_x2 - m_x2 / 5, # right pick below - m_x1 + (m_x2 - m_x1) / 2, # mid pick below - m_x1 + m_x2 / 5, # left pick below - ] - m_y1 = (r4 - r5) / 2 * 1.25 # horizontal gab between the letters G and M - m_y2 = r4 - m_y = [ - m_y1, # vertical left upwards - m_y1, - m_y2, - m_y2, - r5, #m_y2 - m_y2 / 4, # mid pick above - m_y2, # vertical right downwards - m_y2, - m_y1, - m_y1, - r5, #m_y2 - m_y2 / 3, # right pick below - r5 - (r4 - r5), #m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below - r5, #m_y2 - m_y2 / 3, # left pick below - ] - return m_x, m_y, m_x1, m_x2 - - def _letter_t_coords(): - """Coordinates of the top curved horizontal line for letter T.""" - outer_angles = np.deg2rad(np.arange(150, 210)) - inner_angles = outer_angles[::-1] - t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) - t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) - # Ensure the same X coordinate for the right edge of T and the middle of M. - mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2) - return {"x": t_x[mask], "y": t_y[mask]} - - def _compass_lines(): - """ - Coordinates of compass lines. - Plot vertical line on top of letters G and M again at the end. - """ - x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 - compass_lines = [ - ([-r0 * hex_factor, -r3], [0, 0]), # horizontal lines - ([-r5, 0], [0, 0]), - ([r3, r0 * hex_factor], [0, 0]), - ([0, 0], [-r3, 0]), # vertical line - ([-x1, -x2], [x1, x2]), # upper left - ([-x1, -x2], [-x1, -x2]), # lower left - ([x1, x2 + (r4 - r5)], [x1, x2 + (r4 - r5)]), # upper right - ([x1, x2], [-x1, -x2]), # lower right - ] - return compass_lines - - def _red_line_coords(): - """Coordinates of upper vertical red line.""" - red_line_x = [0, 0] - red_line_y = [vline_y, r3] - return red_line_x, red_line_y - - fig = pygmt.Figure() - fig.basemap( - region=region, projection=projection, perspective=perspective, frame="none" - ) - - args_shape = { - "x": 0, - "y": 0, - "style": f"{symbol}{size_shape}c", - "perspective": True, - "no_clip": True, # Needed for corners of hexagon shape - } - # White filled circle / hexagon for Earth - fig.plot(fill=color_bg, **args_shape) - # fig.show() - - compass_lines = _compass_lines() - # Non-horizontal compass lines - for x, y in compass_lines[4:]: - fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) - # fig.show() - - # Blue outlined circle / hexagon for Earth - fig.plot(pen=f"{thick}c,{blue}", **args_shape) - # fig.show() - - # Horizontal compass lines - for x, y in compass_lines[:4]: - fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) - # fig.show() - - # Letter G - fig.plot(data=_letter_g_coords(), fill=red, perspective=True) - # fig.show() - - # Upper vertical red line - # Space between red line and blue circle / hexagon - red_line_x, red_line_y = _red_line_coords() - fig.plot( - x=red_line_x, y=red_line_y, pen=f"{middle * 1.45}c,{color_bg}", perspective=True - ) - # fig.show() - # red line - fig.plot(x=red_line_x, y=red_line_y, pen=f"{middle}c,{red}", perspective=True) - # fig.show() - - # Letter M - m_x, m_y, m_x1, m_x2 = _letter_m_coords() - fig.plot(x=m_x, y=m_y, fill=red, perspective=True) - # fig.show() - - # Letter T: red curved horizontal line - fig.plot(data=_letter_t_coords(), fill=red, perspective=True) - # fig.show() - - # The arrow - fig.plot( - data=[[0, -r2, 0, arrow_y * 1.05]], - pen=color_bg, - style=f"v{thick * 1.45}c+s+e+h0+a60+g{color_bg}", - perspective=True, - ) - # fig.show() - fig.plot( - data=[[0, -r3, 0, arrow_y]], - pen=f"{middle}c,{red}", - style=f"v{thick * 1.4}c+s+e+h0+a60+g{red}", - perspective=True, - ) - # fig.show() - - # Extra vertical compass line above letters G and M. - fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"{thin}c,{yellow}", perspective=True) - # fig.show() - - # 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 + size_shape_add}c", - pen=f"1p,{color_dark}", - perspective=True, - no_clip=True, - ) - # fig.show() - - # Add wordmark "PyGMT" - if wordmark: - text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" - fig.text(text=text_wm, no_clip=True, **args_text_wm) - # fig.show() - - # Helpful for implementing the logo; not included in the logo - # Circles for the different radii - # for r in [r0, r1, r2, r3, r4, r5, r2 + (r3 - r4)]: - # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") - # Map frame with annotations, tick marks, and gridlines - # with pygmt.config(MAP_FRAME_TYPE="inside"): - # fig.basemap(frame="a1g1") - - # fig.show() - fig_name_logo = "pygmt_logo" - fig.savefig(fname=f"{fig_name_logo}.eps") - - return fig_name_logo - - -def pygmtlogo( # noqa: PLR0913 - self, - color=True, - theme="light", - shape="circle", - wordmark=True, - position=None, # -> Use position parameter of Figure.image - box=None, # -> Use box parameter of Figure.image - projection=None, - region=None, - verbose=None, - panel=None, - transparency=None, -): - """ - Plot the PyGMT logo. - The design of the logo is kindly provided by `@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 [gray20] background). - wordmark - Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set - to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the - visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and - ``False`` to add no wordmark. - color - Set to ``True`` to use colors referring to Python (blue and yellow) and GMT - (red) [Default]. For ``False``, the logo is drawn in black and white. - """ - - # ----------------------------------------------------------------------------- - # Create logo file - # ----------------------------------------------------------------------------- - fig_name_logo = create_logo( - color=color, theme=theme, shape=shape, wordmark=wordmark - ) - - # ----------------------------------------------------------------------------- - # Add to existing Figure instance - # ----------------------------------------------------------------------------- - self.image( - imagefile=f"{fig_name_logo}.eps", - position=position, - box=box, - projection=projection, - region=region, - verbose=verbose, - panel=panel, - transparency=transparency, - ) - - Path.unlink(f"{fig_name_logo}.eps") +""" +pygmtlogo - Create and plot the PyGMT logo. +The design of the logo is kindly provided by `@sfrooti `_ +and consists of a visual and the wordmark "PyGMT". +""" + +from pathlib import Path +from typing import Literal + +import numpy as np +import pygmt + + +def create_logo( # noqa: PLR0915 + shape: Literal["circle", "hexagon"] = "circle", + theme: Literal["light", "dark"] = "light", + wordmark: Literal["horizontal", "vertical"] | bool = True, + color: bool = True, +): + """ + Create the PyGMT logo using PyGMT. + The design of the logo is kindly provided by `@sfrooti `_ + and consists of a visual and the wordmark "PyGMT". + """ + + # Helpful definitions + size = 4 + region = [-size, size] * 2 + projection = "x1c" + + # Radii + r0, r1, r2, r3, r4, r5 = size * np.array( + [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] + ) + # Pen thicknesses + thicker = r0 - r1 # for shape + thick = r4 - r5 # for letters + thin = thicker / 3 # for compass lines + + # Rotation around z (vertical) axis placed in the center + # Has to be applied to each plotting command, up on second call set to True + perspective = "30+w0/0" # by 30 degrees counter-clockwise + + # 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" # circle + size_shape = r0 + r1 # radius + size_shape_add = r0 - r1 + hex_factor = 1 + vline_y = r0 + arrow_y = -r0 + case "hexagon": + symbol = "h" # hexagon + size_shape = (r0 - 0.3) * 2 # diameter + size_shape_add = 0.6 + hex_factor = 0.98 + vline_y = r1 * 0.99 + arrow_y = -r1 * 0.99 + + # 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 True | "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 = (r4 - r5) / 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.""" + m_x1 = thin / 2 # Half of the pen thickness of compass lines. + m_x2 = r4 + m_x = [ + m_x1 + m_x2 / 5, # vertical left upwards + m_x1, + m_x1, + m_x1 + m_x2 / 5, + m_x1 + (m_x2 - m_x1) / 2, # mid pick above + m_x2 - m_x2 / 5, # vertical right downwards + m_x2, + m_x2, + m_x2 - m_x2 / 5, + m_x2 - m_x2 / 5, # right pick below + m_x1 + (m_x2 - m_x1) / 2, # mid pick below + m_x1 + m_x2 / 5, # left pick below + ] + m_y1 = (r4 - r5) / 2 * 1.25 # horizontal gab between the letters G and M + m_y2 = r4 + m_y = [ + m_y1, # vertical left upwards + m_y1, + m_y2, + m_y2, + r5, # m_y2 - m_y2 / 4, # mid pick above + m_y2, # vertical right downwards + m_y2, + m_y1, + m_y1, + r5, # m_y2 - m_y2 / 3, # right pick below + r5 - (r4 - r5), # m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below + r5, # m_y2 - m_y2 / 3, # left pick below + ] + return m_x, m_y, m_x1, m_x2 + + def _letter_t_coords(): + """Coordinates of the top curved horizontal line for letter T.""" + outer_angles = np.deg2rad(np.arange(150, 210)) + inner_angles = outer_angles[::-1] + t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) + t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) + # Ensure the same X coordinate for the right edge of T and the middle of M. + mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2) + return {"x": t_x[mask], "y": t_y[mask]} + + def _compass_lines(): + """ + Coordinates of compass lines. + Plot vertical line on top of letters G and M again at the end. + """ + x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 + compass_lines = [ + ([-r0 * hex_factor, -r3], [0, 0]), # horizontal lines + ([-r5, 0], [0, 0]), + ([r3, r0 * hex_factor], [0, 0]), + ([0, 0], [-r3, 0]), # vertical line + ([-x1, -x2], [x1, x2]), # upper left + ([-x1, -x2], [-x1, -x2]), # lower left + ([x1, x2 + (r4 - r5)], [x1, x2 + (r4 - r5)]), # upper right + ([x1, x2], [-x1, -x2]), # lower right + ] + return compass_lines + + def _red_line_coords(): + """Coordinates of upper vertical red line.""" + red_line_x = [0, 0] + red_line_y = [vline_y, r3] + return red_line_x, red_line_y + + fig = pygmt.Figure() + fig.basemap( + region=region, projection=projection, perspective=perspective, frame="none" + ) + + args_shape = { + "x": 0, + "y": 0, + "style": f"{symbol}{size_shape}c", + "perspective": True, + "no_clip": True, # Needed for corners of hexagon shape + } + # White filled circle / hexagon for Earth + fig.plot(fill=color_bg, **args_shape) + # fig.show() + + compass_lines = _compass_lines() + # Non-horizontal compass lines + for x, y in compass_lines[4:]: + fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) + # fig.show() + + # Blue outlined circle / hexagon for Earth + fig.plot(pen=f"{thicker}c,{blue}", **args_shape) + # fig.show() + + # Horizontal compass lines + for x, y in compass_lines[:4]: + fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) + # fig.show() + + # Letter G + fig.plot(data=_letter_g_coords(), fill=red, perspective=True) + # fig.show() + + # Upper vertical red line + # Space between red line and blue circle / hexagon + red_line_x, red_line_y = _red_line_coords() + fig.plot( + x=red_line_x, y=red_line_y, pen=f"{thick * 1.45}c,{color_bg}", perspective=True + ) + # fig.show() + # red line + fig.plot(x=red_line_x, y=red_line_y, pen=f"{thick}c,{red}", perspective=True) + # fig.show() + + # Letter M + m_x, m_y, m_x1, m_x2 = _letter_m_coords() + fig.plot(x=m_x, y=m_y, fill=red, perspective=True) + # fig.show() + + # Letter T: red curved horizontal line + fig.plot(data=_letter_t_coords(), fill=red, perspective=True) + # fig.show() + + # The arrow + fig.plot( + data=[[0, -r2, 0, arrow_y * 1.05]], + pen=color_bg, + style=f"v{thicker * 1.45}c+s+e+h0+a60+g{color_bg}", + perspective=True, + ) + # fig.show() + fig.plot( + data=[[0, -r3, 0, arrow_y]], + pen=f"{thick}c,{red}", + style=f"v{thicker * 1.4}c+s+e+h0+a60+g{red}", + perspective=True, + ) + # fig.show() + + # Extra vertical compass line above letters G and M. + fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"{thin}c,{yellow}", perspective=True) + # fig.show() + + # 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 + size_shape_add}c", + pen=f"1p,{color_dark}", + perspective=True, + no_clip=True, + ) + # fig.show() + + # Add wordmark "PyGMT" + if wordmark: + text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" + fig.text(text=text_wm, no_clip=True, **args_text_wm) + # fig.show() + + # Helpful for implementing the logo; not included in the logo + # Circles for the different radii + # for r in [r0, r1, r2, r3, r4, r5, r2 + (r3 - r4)]: + # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") + # Map frame with annotations, tick marks, and gridlines + # with pygmt.config(MAP_FRAME_TYPE="inside"): + # fig.basemap(frame="a1g1") + + # fig.show() + fig_name_logo = "pygmt_logo" + fig.savefig(fname=f"{fig_name_logo}.eps") + + return fig_name_logo + + +def pygmtlogo( # noqa: PLR0913 + self, + color=True, + theme="light", + shape="circle", + wordmark=True, + position=None, # -> Use position parameter of Figure.image + box=None, # -> Use box parameter of Figure.image + projection=None, + region=None, + verbose=None, + panel=None, + transparency=None, +): + """ + Plot the PyGMT logo. + The design of the logo is kindly provided by `@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 [gray20] background). + wordmark + Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set + to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the + visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and + ``False`` to add no wordmark. + color + Set to ``True`` to use colors referring to Python (blue and yellow) and GMT + (red) [Default]. For ``False``, the logo is drawn in black and white. + """ + + # ----------------------------------------------------------------------------- + # Create logo file + # ----------------------------------------------------------------------------- + fig_name_logo = create_logo( + color=color, theme=theme, shape=shape, wordmark=wordmark + ) + + # ----------------------------------------------------------------------------- + # Add to existing Figure instance + # ----------------------------------------------------------------------------- + self.image( + imagefile=f"{fig_name_logo}.eps", + position=position, + box=box, + projection=projection, + region=region, + verbose=verbose, + panel=panel, + transparency=transparency, + ) + + Path.unlink(f"{fig_name_logo}.eps") From a7f326c1bc046e42e4f3d342ce60001fa40640b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 10:37:38 +0200 Subject: [PATCH 270/379] Define fourth pen thickness 'thinner' for letter M to define variables outside of private functions --- pygmt/src/pygmtlogo.py | 47 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index f985067993b..a300038745d 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -34,8 +34,9 @@ def create_logo( # noqa: PLR0915 ) # Pen thicknesses thicker = r0 - r1 # for shape - thick = r4 - r5 # for letters + thick = r4 - r5 # for letters G and T thin = thicker / 3 # for compass lines + thinner = thin / 2 # for letter M # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True @@ -105,41 +106,39 @@ def _letter_g_coords(): g_y = np.concatenate([arc_outer_y, connector_y, arc_inner_y]) return {"x": g_x, "y": g_y} + # m_x2 = r4 def _letter_m_coords(): """Coordinates for letter M.""" - m_x1 = thin / 2 # Half of the pen thickness of compass lines. - m_x2 = r4 m_x = [ - m_x1 + m_x2 / 5, # vertical left upwards - m_x1, - m_x1, - m_x1 + m_x2 / 5, - m_x1 + (m_x2 - m_x1) / 2, # mid pick above - m_x2 - m_x2 / 5, # vertical right downwards - m_x2, - m_x2, - m_x2 - m_x2 / 5, - m_x2 - m_x2 / 5, # right pick below - m_x1 + (m_x2 - m_x1) / 2, # mid pick below - m_x1 + m_x2 / 5, # left pick below + thinner + r4 / 5, # vertical left upwards + thinner, + thinner, + thinner + r4 / 5, + thinner + (r4 - thinner) / 2, # mid pick above + r4 - r4 / 5, # vertical right downwards + r4, + r4, + r4 - r4 / 5, + r4 - r4 / 5, # right pick below + thinner + (r4 - thinner) / 2, # mid pick below + thinner + r4 / 5, # left pick below ] m_y1 = (r4 - r5) / 2 * 1.25 # horizontal gab between the letters G and M - m_y2 = r4 m_y = [ m_y1, # vertical left upwards m_y1, - m_y2, - m_y2, + r4, + r4, r5, # m_y2 - m_y2 / 4, # mid pick above - m_y2, # vertical right downwards - m_y2, + r4, # vertical right downwards + r4, m_y1, m_y1, r5, # m_y2 - m_y2 / 3, # right pick below r5 - (r4 - r5), # m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below r5, # m_y2 - m_y2 / 3, # left pick below ] - return m_x, m_y, m_x1, m_x2 + return {"x": m_x, "y": m_y} def _letter_t_coords(): """Coordinates of the top curved horizontal line for letter T.""" @@ -148,7 +147,7 @@ def _letter_t_coords(): t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) # Ensure the same X coordinate for the right edge of T and the middle of M. - mask = np.abs(t_x) <= (m_x1 + (m_x2 - m_x1) / 2) + mask = np.abs(t_x) <= (thinner + (r4 - thinner) / 2) return {"x": t_x[mask], "y": t_y[mask]} def _compass_lines(): @@ -175,6 +174,7 @@ def _red_line_coords(): red_line_y = [vline_y, r3] return red_line_x, red_line_y + # %% fig = pygmt.Figure() fig.basemap( region=region, projection=projection, perspective=perspective, frame="none" @@ -222,8 +222,7 @@ def _red_line_coords(): # fig.show() # Letter M - m_x, m_y, m_x1, m_x2 = _letter_m_coords() - fig.plot(x=m_x, y=m_y, fill=red, perspective=True) + fig.plot(data=_letter_m_coords(), fill=red, perspective=True) # fig.show() # Letter T: red curved horizontal line From 0175f7f312881e4f2f5e7c4a5bcf97e92b7d8310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 11:06:43 +0200 Subject: [PATCH 271/379] Remove old definition of letter M, improve definition of m_y1 --- pygmt/src/pygmtlogo.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index a300038745d..d92489a0531 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -106,7 +106,6 @@ def _letter_g_coords(): g_y = np.concatenate([arc_outer_y, connector_y, arc_inner_y]) return {"x": g_x, "y": g_y} - # m_x2 = r4 def _letter_m_coords(): """Coordinates for letter M.""" m_x = [ @@ -123,20 +122,20 @@ def _letter_m_coords(): thinner + (r4 - thinner) / 2, # mid pick below thinner + r4 / 5, # left pick below ] - m_y1 = (r4 - r5) / 2 * 1.25 # horizontal gab between the letters G and M + m_y1 = thick / 2 + thinner # horizontal gab between the letters G and M m_y = [ m_y1, # vertical left upwards m_y1, r4, r4, - r5, # m_y2 - m_y2 / 4, # mid pick above + r5, # mid pick above r4, # vertical right downwards r4, m_y1, m_y1, - r5, # m_y2 - m_y2 / 3, # right pick below - r5 - (r4 - r5), # m_y2 - m_y2 / 2 - m_y2 / 18, # mid pick below - r5, # m_y2 - m_y2 / 3, # left pick below + r5, # right pick below + r5 - thick, # mid pick below + r5, # left pick below ] return {"x": m_x, "y": m_y} From 8f9e32e37f960a11909b0f78babaeb734a1fe749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 11:38:04 +0200 Subject: [PATCH 272/379] Make gaps consistent --- pygmt/src/pygmtlogo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d92489a0531..0271d3fda1a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -213,7 +213,7 @@ def _red_line_coords(): # Space between red line and blue circle / hexagon red_line_x, red_line_y = _red_line_coords() fig.plot( - x=red_line_x, y=red_line_y, pen=f"{thick * 1.45}c,{color_bg}", perspective=True + x=red_line_x, y=red_line_y, pen=f"{thick + thin}c,{color_bg}", perspective=True ) # fig.show() # red line @@ -232,14 +232,14 @@ def _red_line_coords(): fig.plot( data=[[0, -r2, 0, arrow_y * 1.05]], pen=color_bg, - style=f"v{thicker * 1.45}c+s+e+h0+a60+g{color_bg}", + style=f"v{thicker + thin * 2}c+s+e+h0+a60+g{color_bg}", perspective=True, ) # fig.show() fig.plot( data=[[0, -r3, 0, arrow_y]], pen=f"{thick}c,{red}", - style=f"v{thicker * 1.4}c+s+e+h0+a60+g{red}", + style=f"v{thicker + thin}c+s+e+h0+a60+g{red}", perspective=True, ) # fig.show() From c60018e129ac6b65e1c87d884dd890df7b79efe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 11:41:02 +0200 Subject: [PATCH 273/379] Use pen thickness variable --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 0271d3fda1a..791856c7fe6 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -245,7 +245,7 @@ def _red_line_coords(): # fig.show() # Extra vertical compass line above letters G and M. - fig.plot(x=[0, 0], y=[-r5 * 0.9, r3], pen=f"{thin}c,{yellow}", perspective=True) + fig.plot(x=[0, 0], y=[-thicker / 2, r3], pen=f"{thin}c,{yellow}", perspective=True) # fig.show() # Outline around the shape for black and white color with dark theme From 8001dd22bf55c21917e39e163d0852c79500212b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 11:56:50 +0200 Subject: [PATCH 274/379] Use for descripte variable names for pen thicknesses and introduce pen thickness for letter M --- pygmt/src/pygmtlogo.py | 61 ++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 791856c7fe6..e1c663fc5d2 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -33,10 +33,11 @@ def create_logo( # noqa: PLR0915 [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] ) # Pen thicknesses - thicker = r0 - r1 # for shape - thick = r4 - r5 # for letters G and T - thin = thicker / 3 # for compass lines - thinner = thin / 2 # for letter M + 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_gt / 3 # for compass lines + thick_gap = thick_comp / 2 # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True @@ -109,20 +110,20 @@ def _letter_g_coords(): def _letter_m_coords(): """Coordinates for letter M.""" m_x = [ - thinner + r4 / 5, # vertical left upwards - thinner, - thinner, - thinner + r4 / 5, - thinner + (r4 - thinner) / 2, # mid pick above - r4 - r4 / 5, # vertical right downwards + thick_gap + thick_m, # vertical left upwards + thick_gap, + thick_gap, + thick_gap + thick_m, + thick_gap + (r4 - thick_gap) / 2, # mid pick above + r4 - thick_m, # vertical right downwards r4, r4, - r4 - r4 / 5, - r4 - r4 / 5, # right pick below - thinner + (r4 - thinner) / 2, # mid pick below - thinner + r4 / 5, # left pick below + r4 - thick_m, + r4 - thick_m, # right pick below + thick_gap + (r4 - thick_gap) / 2, # mid pick below + thick_gap + thick_m, # left pick below ] - m_y1 = thick / 2 + thinner # horizontal gab between the letters G and M + m_y1 = thick_gt / 2 + thick_gap # horizontal gab between the letters G and M m_y = [ m_y1, # vertical left upwards m_y1, @@ -134,7 +135,7 @@ def _letter_m_coords(): m_y1, m_y1, r5, # right pick below - r5 - thick, # mid pick below + r5 - thick_gt, # mid pick below r5, # left pick below ] return {"x": m_x, "y": m_y} @@ -146,7 +147,7 @@ def _letter_t_coords(): t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) # Ensure the same X coordinate for the right edge of T and the middle of M. - mask = np.abs(t_x) <= (thinner + (r4 - thinner) / 2) + mask = np.abs(t_x) <= (thick_gap + (r4 - thick_gap) / 2) return {"x": t_x[mask], "y": t_y[mask]} def _compass_lines(): @@ -193,16 +194,16 @@ def _red_line_coords(): compass_lines = _compass_lines() # Non-horizontal compass lines for x, y in compass_lines[4:]: - fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) + fig.plot(x=x, y=y, pen=f"{thick_comp}c,{yellow}", perspective=True) # fig.show() # Blue outlined circle / hexagon for Earth - fig.plot(pen=f"{thicker}c,{blue}", **args_shape) + fig.plot(pen=f"{thick_shape}c,{blue}", **args_shape) # fig.show() # Horizontal compass lines for x, y in compass_lines[:4]: - fig.plot(x=x, y=y, pen=f"{thin}c,{yellow}", perspective=True) + fig.plot(x=x, y=y, pen=f"{thick_comp}c,{yellow}", perspective=True) # fig.show() # Letter G @@ -213,11 +214,14 @@ def _red_line_coords(): # Space between red line and blue circle / hexagon red_line_x, red_line_y = _red_line_coords() fig.plot( - x=red_line_x, y=red_line_y, pen=f"{thick + thin}c,{color_bg}", perspective=True + x=red_line_x, + y=red_line_y, + pen=f"{thick_gt + thick_comp}c,{color_bg}", + perspective=True, ) # fig.show() # red line - fig.plot(x=red_line_x, y=red_line_y, pen=f"{thick}c,{red}", perspective=True) + fig.plot(x=red_line_x, y=red_line_y, pen=f"{thick_gt}c,{red}", perspective=True) # fig.show() # Letter M @@ -232,20 +236,25 @@ def _red_line_coords(): fig.plot( data=[[0, -r2, 0, arrow_y * 1.05]], pen=color_bg, - style=f"v{thicker + thin * 2}c+s+e+h0+a60+g{color_bg}", + style=f"v{thick_shape + thick_comp * 2}c+s+e+h0+a60+g{color_bg}", perspective=True, ) # fig.show() fig.plot( data=[[0, -r3, 0, arrow_y]], - pen=f"{thick}c,{red}", - style=f"v{thicker + thin}c+s+e+h0+a60+g{red}", + pen=f"{thick_gt}c,{red}", + style=f"v{thick_shape + thick_comp}c+s+e+h0+a60+g{red}", perspective=True, ) # fig.show() # Extra vertical compass line above letters G and M. - fig.plot(x=[0, 0], y=[-thicker / 2, r3], pen=f"{thin}c,{yellow}", perspective=True) + fig.plot( + x=[0, 0], + y=[-thick_shape / 2, r3], + pen=f"{thick_comp}c,{yellow}", + perspective=True, + ) # fig.show() # Outline around the shape for black and white color with dark theme From af31fa2622be9635d401e72482faa20d0e677c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 12:16:36 +0200 Subject: [PATCH 275/379] Redefine coordinates for letter M Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e1c663fc5d2..bae009e0142 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -109,35 +109,21 @@ def _letter_g_coords(): def _letter_m_coords(): """Coordinates for letter M.""" - m_x = [ - thick_gap + thick_m, # vertical left upwards - thick_gap, - thick_gap, - thick_gap + thick_m, - thick_gap + (r4 - thick_gap) / 2, # mid pick above - r4 - thick_m, # vertical right downwards - r4, - r4, - r4 - thick_m, - r4 - thick_m, # right pick below - thick_gap + (r4 - thick_gap) / 2, # mid pick below - thick_gap + thick_m, # left pick below - ] + # X coordinates from left to right. + m_x1 = thick_gap # Left edge of left vertical line of M. + m_x5 = r4 # Right edge of right vertical line of M. + m_x2 = m_x1 + thick_m # Right edge of left vertical line of M. + m_x3 = (m_x1 + m_x5) / 2 # The middle of M. + m_x4 = m_x5 - thick_m # Left edge of right vertical line of M. + # Y coordinates from bottom to top. m_y1 = thick_gt / 2 + thick_gap # horizontal gab between the letters G and M - m_y = [ - m_y1, # vertical left upwards - m_y1, - r4, - r4, - r5, # mid pick above - r4, # vertical right downwards - r4, - m_y1, - m_y1, - r5, # right pick below - r5 - thick_gt, # mid pick below - r5, # left pick below - ] + m_y2 = r5 - (r4 - r5) # Bottom of the middle peak of M. + m_y3 = r5 # Top of the middle peak of M. + 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 = [m_x1, m_x1, m_x2, m_x3, m_x4, m_x5, m_x5, m_x4, m_x4, m_x3, m_x2, m_x2] + m_y = [m_y1, m_y4, m_y4, m_y3, m_y4, m_y4, m_y1, m_y1, m_y3, m_y2, m_y3, m_y1] return {"x": m_x, "y": m_y} def _letter_t_coords(): From 9c2c36f885adedc9d66611273b5e634656d1aa5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 19 Apr 2026 12:58:30 +0200 Subject: [PATCH 276/379] Use variable "thick_gt" Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index bae009e0142..04a95ee0fb5 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -95,7 +95,7 @@ def _letter_g_coords(): """Coordinates for letter G.""" outer_angles = np.deg2rad(np.arange(90, 361)) inner_angles = outer_angles[::-1] - offset = (r4 - r5) / 2 + 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 @@ -117,7 +117,7 @@ def _letter_m_coords(): m_x4 = m_x5 - thick_m # Left edge of right vertical line of M. # Y coordinates from bottom to top. m_y1 = thick_gt / 2 + thick_gap # horizontal gab between the letters G and M - m_y2 = r5 - (r4 - r5) # Bottom of the middle peak of M. + m_y2 = r5 - thick_gt # Bottom of the middle peak of M. m_y3 = r5 # Top of the middle peak of M. m_y4 = r4 # Top of letter M. # X- and Y-coordinates of the letter M, starting from the left edge of the left From 130d1c39040733c1d64a0e1b6f5c736b435d0065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 19 Apr 2026 13:01:20 +0200 Subject: [PATCH 277/379] Simplify condition for mask for letter T Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 04a95ee0fb5..81ffc862cbb 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -133,7 +133,7 @@ def _letter_t_coords(): t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) # Ensure the same X coordinate for the right edge of T and the middle of M. - mask = np.abs(t_x) <= (thick_gap + (r4 - thick_gap) / 2) + mask = np.abs(t_x) <= (thick_gap + r4) / 2 return {"x": t_x[mask], "y": t_y[mask]} def _compass_lines(): From 1a737085cb8701a252889547500a672484803b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 13:06:14 +0200 Subject: [PATCH 278/379] Shorten variable names for coordinates of letter M --- pygmt/src/pygmtlogo.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 81ffc862cbb..4b798bc8947 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -110,20 +110,20 @@ def _letter_g_coords(): def _letter_m_coords(): """Coordinates for letter M.""" # X coordinates from left to right. - m_x1 = thick_gap # Left edge of left vertical line of M. - m_x5 = r4 # Right edge of right vertical line of M. - m_x2 = m_x1 + thick_m # Right edge of left vertical line of M. - m_x3 = (m_x1 + m_x5) / 2 # The middle of M. - m_x4 = m_x5 - thick_m # Left edge of right vertical line of M. + 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. - m_y1 = thick_gt / 2 + thick_gap # horizontal gab between the letters G and M - m_y2 = r5 - thick_gt # Bottom of the middle peak of M. - m_y3 = r5 # Top of the middle peak of M. - m_y4 = r4 # Top of letter M. + y1 = thick_gt / 2 + thick_gap # horizontal gab between the letters G and 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 = [m_x1, m_x1, m_x2, m_x3, m_x4, m_x5, m_x5, m_x4, m_x4, m_x3, m_x2, m_x2] - m_y = [m_y1, m_y4, m_y4, m_y3, m_y4, m_y4, m_y1, m_y1, m_y3, m_y2, m_y3, m_y1] + 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(): From 0789876e5a48d8e57ef4169bb37db944bd99e433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 13:58:44 +0200 Subject: [PATCH 279/379] Make gap for arrow head consistent with the other gaps --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4b798bc8947..6890ef94d3b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -220,7 +220,7 @@ def _red_line_coords(): # The arrow fig.plot( - data=[[0, -r2, 0, arrow_y * 1.05]], + data=[[0, -r2, 0, arrow_y - thick_comp]], pen=color_bg, style=f"v{thick_shape + thick_comp * 2}c+s+e+h0+a60+g{color_bg}", perspective=True, From a00e695a2cda867b2ab4350771af601573a0c6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 19 Apr 2026 14:02:24 +0200 Subject: [PATCH 280/379] Improve comment Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6890ef94d3b..11392dd6c70 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -116,7 +116,7 @@ def _letter_m_coords(): 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 # horizontal gab between the letters G and M + 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. From bafc7a00c645c49ff1eef506c22d700c2ece060a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 19 Apr 2026 14:26:23 +0200 Subject: [PATCH 281/379] Define compass lines as vectors Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 51 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 11392dd6c70..0847ed68c2f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -142,17 +142,22 @@ def _compass_lines(): Plot vertical line on top of letters G and M again at the end. """ x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 - compass_lines = [ - ([-r0 * hex_factor, -r3], [0, 0]), # horizontal lines - ([-r5, 0], [0, 0]), - ([r3, r0 * hex_factor], [0, 0]), - ([0, 0], [-r3, 0]), # vertical line - ([-x1, -x2], [x1, x2]), # upper left - ([-x1, -x2], [-x1, -x2]), # lower left - ([x1, x2 + (r4 - r5)], [x1, x2 + (r4 - r5)]), # upper right - ([x1, x2], [-x1, -x2]), # lower right - ] - return compass_lines + # Coordinates of vectors in the format of (x_start, y_start, x_end, y_end). + return { + "hline": [ + (-r0 * hex_factor, 0, -r3, 0), + (-r5, 0, 0, 0), + (r3, 0, r0 * hex_factor, 0), + ], + "diagonal": [ + (-x1, x1, -x2, x2), # upper left + (-x1, -x1, -x2, -x2), # lower left + (x1, x1, x2 + (r4 - r5), x2 + (r4 - r5)), # upper right + (x1, -x1, x2, -x2), # lower right + ], + "vline1": [(0, -r3, 0, 0)], + "vline2": [(0, -thick_shape / 2, 0, r3)], + } def _red_line_coords(): """Coordinates of upper vertical red line.""" @@ -178,19 +183,19 @@ def _red_line_coords(): # fig.show() compass_lines = _compass_lines() + args_compass = { + "pen": f"{thick_comp}c,{yellow}", "perspective": True, "style": "v0c+s", + } # Non-horizontal compass lines - for x, y in compass_lines[4:]: - fig.plot(x=x, y=y, pen=f"{thick_comp}c,{yellow}", perspective=True) - # fig.show() + fig.plot(data=compass_lines["diagonal"], **args_compass) # Blue outlined circle / hexagon for Earth fig.plot(pen=f"{thick_shape}c,{blue}", **args_shape) # fig.show() - # Horizontal compass lines - for x, y in compass_lines[:4]: - fig.plot(x=x, y=y, pen=f"{thick_comp}c,{yellow}", perspective=True) - # fig.show() + # Horizontal and vertical compass lines + fig.plot(data=compass_lines["hline"], **args_compass) + fig.plot(data=compass_lines["vline1"], **args_compass) # Letter G fig.plot(data=_letter_g_coords(), fill=red, perspective=True) @@ -234,14 +239,8 @@ def _red_line_coords(): ) # fig.show() - # Extra vertical compass line above letters G and M. - fig.plot( - x=[0, 0], - y=[-thick_shape / 2, r3], - pen=f"{thick_comp}c,{yellow}", - perspective=True, - ) - # fig.show() + # Vertical compass line above letters G and M. + fig.plot(data=compass_lines["vline2"], **args_compass) # Outline around the shape for black and white color with dark theme if not color and theme == "dark": From 9b4bd13e6e7975625df16f85c9480f2987e4b7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 15:06:29 +0200 Subject: [PATCH 282/379] Fix typo --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 0847ed68c2f..7833763de00 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -109,13 +109,13 @@ def _letter_g_coords(): def _letter_m_coords(): """Coordinates for letter M.""" - # X coordinates from left to right. + # 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. + # 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. From 6e7fc83493dd6986ac9fdaa8bb17425943168036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 15:30:26 +0200 Subject: [PATCH 283/379] Fix typo --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 7833763de00..6f0367a172f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -132,7 +132,7 @@ def _letter_t_coords(): inner_angles = outer_angles[::-1] t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) - # Ensure the same X coordinate for the right edge of T and the middle of M. + # 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]} From f171ab4699238845e29ce0f18d80c5873e9067d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 18:12:20 +0200 Subject: [PATCH 284/379] Add note regarding radii --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6f0367a172f..f7f0ce3fce8 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -28,7 +28,7 @@ def create_logo( # noqa: PLR0915 region = [-size, size] * 2 projection = "x1c" - # Radii + # Radii (make sure that r4-r5 == r2-r3) r0, r1, r2, r3, r4, r5 = size * np.array( [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] ) From d0c8fda226c24fb0f8469808745d3369e066826f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 18:33:16 +0200 Subject: [PATCH 285/379] Fix line length, add more help lines --- pygmt/src/pygmtlogo.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index f7f0ce3fce8..cd5403c4566 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -184,7 +184,9 @@ def _red_line_coords(): compass_lines = _compass_lines() args_compass = { - "pen": f"{thick_comp}c,{yellow}", "perspective": True, "style": "v0c+s", + "pen": f"{thick_comp}c,{yellow}", + "perspective": True, + "style": "v0c+s", } # Non-horizontal compass lines fig.plot(data=compass_lines["diagonal"], **args_compass) @@ -260,13 +262,17 @@ def _red_line_coords(): fig.text(text=text_wm, no_clip=True, **args_text_wm) # fig.show() - # Helpful for implementing the logo; not included in the logo - # Circles for the different radii - # for r in [r0, r1, r2, r3, r4, r5, r2 + (r3 - r4)]: - # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.8p,black,dashed") - # Map frame with annotations, tick marks, and gridlines - # with pygmt.config(MAP_FRAME_TYPE="inside"): - # fig.basemap(frame="a1g1") + # # Helpful for implementing the logo; not included in the logo + # Gridlines + # with pygmt.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,4_2") + # fig.plot(x=0, y=0, style=f"c{2 * (r2 + (r3 - r4))}c", pen="0.3p,gray30,2_2") + # # Lines for letter M + # fig.hlines(y=[r4, r5], pen="0.3p,gray30,2_2") + # fig.vlines(x=r4, pen="0.3p,gray30,2_2") # fig.show() fig_name_logo = "pygmt_logo" From 1766e9cca8418aaf568f2765588ea8ef4e7401d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 19 Apr 2026 18:44:28 +0200 Subject: [PATCH 286/379] Define variable x3 for curved top line of letter T MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index cd5403c4566..43b6fc23da5 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -141,7 +141,8 @@ def _compass_lines(): Coordinates of compass lines. Plot vertical line on top of letters G and M again at the end. """ - x1, x2 = r1 * 0.7071, r3 * 0.7071 # sqrt(2)/2 = 0.7071 + sqrt2 = np.sqrt(2) / 2 + x1, x2, x3 = r1 * sqrt2, r3 * sqrt2, (r2 + (r3 - r4)) * sqrt2 # Coordinates of vectors in the format of (x_start, y_start, x_end, y_end). return { "hline": [ @@ -152,7 +153,7 @@ def _compass_lines(): "diagonal": [ (-x1, x1, -x2, x2), # upper left (-x1, -x1, -x2, -x2), # lower left - (x1, x1, x2 + (r4 - r5), x2 + (r4 - r5)), # upper right + (x1, x1, x3, x3), # upper right (x1, -x1, x2, -x2), # lower right ], "vline1": [(0, -r3, 0, 0)], From 7f563e149b48e6529e273c1f0027a2d31e94d869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 19 Apr 2026 19:46:01 +0200 Subject: [PATCH 287/379] Add one more helping line --- pygmt/src/pygmtlogo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 43b6fc23da5..af011b5c574 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -244,6 +244,7 @@ def _red_line_coords(): # Vertical compass line above letters G and M. fig.plot(data=compass_lines["vline2"], **args_compass) + # fig.show() # Outline around the shape for black and white color with dark theme if not color and theme == "dark": @@ -264,16 +265,17 @@ def _red_line_coords(): # fig.show() # # Helpful for implementing the logo; not included in the logo - # Gridlines + # # Gridlines # with pygmt.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,4_2") + # fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.3p,gray30") # fig.plot(x=0, y=0, style=f"c{2 * (r2 + (r3 - r4))}c", pen="0.3p,gray30,2_2") # # Lines for letter M # fig.hlines(y=[r4, r5], pen="0.3p,gray30,2_2") # fig.vlines(x=r4, pen="0.3p,gray30,2_2") + # fig.vlines(x=(thick_gap + r4) / 2, pen="0.3p,gray30,2_2") # fig.show() fig_name_logo = "pygmt_logo" From fe109d9a4f3a9e97f504123443b6d2bdcc93fb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 20 Apr 2026 10:06:12 +0200 Subject: [PATCH 288/379] Use finer discretization for clean endings of top curved line of letter T --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index af011b5c574..d9846db0e5b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -128,7 +128,7 @@ def _letter_m_coords(): def _letter_t_coords(): """Coordinates of the top curved horizontal line for letter T.""" - outer_angles = np.deg2rad(np.arange(150, 210)) + outer_angles = np.deg2rad(np.arange(150, 210, 0.5)) inner_angles = outer_angles[::-1] t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) From 1e889d22ef96763ac884c4f36f8073d33a4eb3ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 20 Apr 2026 10:08:12 +0200 Subject: [PATCH 289/379] Calculate compass line thickness from the thickness of the souronding shape --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d9846db0e5b..461355c71a9 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -36,7 +36,7 @@ def create_logo( # noqa: PLR0915 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_gt / 3 # for compass lines + thick_comp = thick_shape / 3 # for compass lines thick_gap = thick_comp / 2 # Rotation around z (vertical) axis placed in the center From 47b2ca30bddebbd30a8549afda2572458e5310b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 20 Apr 2026 10:12:03 +0200 Subject: [PATCH 290/379] Remove inner compass lines --- pygmt/src/pygmtlogo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 461355c71a9..a0646256603 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -147,7 +147,7 @@ def _compass_lines(): return { "hline": [ (-r0 * hex_factor, 0, -r3, 0), - (-r5, 0, 0, 0), + # (-r5, 0, 0, 0), (r3, 0, r0 * hex_factor, 0), ], "diagonal": [ @@ -189,7 +189,7 @@ def _red_line_coords(): "perspective": True, "style": "v0c+s", } - # Non-horizontal compass lines + # Diagonal compass lines fig.plot(data=compass_lines["diagonal"], **args_compass) # Blue outlined circle / hexagon for Earth @@ -198,7 +198,7 @@ def _red_line_coords(): # Horizontal and vertical compass lines fig.plot(data=compass_lines["hline"], **args_compass) - fig.plot(data=compass_lines["vline1"], **args_compass) + # fig.plot(data=compass_lines["vline1"], **args_compass) # Letter G fig.plot(data=_letter_g_coords(), fill=red, perspective=True) @@ -243,7 +243,7 @@ def _red_line_coords(): # fig.show() # Vertical compass line above letters G and M. - fig.plot(data=compass_lines["vline2"], **args_compass) + # fig.plot(data=compass_lines["vline2"], **args_compass) # fig.show() # Outline around the shape for black and white color with dark theme From 7da60937f1790bb181f49501d01085a8f4f8710e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 20 Apr 2026 13:02:30 +0200 Subject: [PATCH 291/379] Fix typos Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- examples/gallery/embellishments/pygmt_logo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py index e288b175471..db8c5bdf0ee 100644 --- a/examples/gallery/embellishments/pygmt_logo.py +++ b/examples/gallery/embellishments/pygmt_logo.py @@ -5,9 +5,9 @@ to a figure using :meth:`pygmt.Figure.pygmtlogo`. The design of the logo itself is kindly provided by `@sfrooti `_ and consists of a visual and the wordmark "PyGMT". -The logo is available in circle and hexagon shape. It can be plotted using colors of +The logo is available in circle and hexagon shapes. It can be plotted using colors of Python (blue and yellow) and GMT (red) or in black and white as well as in light or -dark mode. The wordmark can be added at the right side or bottom of the visual. +dark mode. The wordmark can be added on the right side or bottom of the visual. """ # %% From 73dc51a3970cb1fec2d7ea32597776a51a4ee861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 20 Apr 2026 13:05:04 +0200 Subject: [PATCH 292/379] Adjust radii and use fractional representation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index a0646256603..43e77b91e85 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -30,7 +30,9 @@ def create_logo( # noqa: PLR0915 # Radii (make sure that r4-r5 == r2-r3) r0, r1, r2, r3, r4, r5 = size * np.array( - [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] + # [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] # old + # [1, 0.875, 0.58125, 0.4825, 0.4125, 0.31375] # exact + [1, 224/256, 150/256, 122/256, 106/256, 78/256] ) # Pen thicknesses thick_shape = r0 - r1 # for shape From 0413225b88a57c1ca509ad964bfb97cce40fa8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 20 Apr 2026 13:06:43 +0200 Subject: [PATCH 293/379] Adjust thickness of gap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 43e77b91e85..17f2a2fec5b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -39,7 +39,7 @@ def create_logo( # noqa: PLR0915 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_comp / 2 + thick_gap = (thick_comp / 4) * 3 # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True From 393a3c4b3bad10d1efc16122d524d86f067cc384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 20 Apr 2026 13:07:52 +0200 Subject: [PATCH 294/379] Plot red vertical line as polygon Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 17f2a2fec5b..616d7443e2f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -162,11 +162,15 @@ def _compass_lines(): "vline2": [(0, -thick_shape / 2, 0, r3)], } - def _red_line_coords(): - """Coordinates of upper vertical red line.""" - red_line_x = [0, 0] - red_line_y = [vline_y, r3] - return red_line_x, red_line_y + def _vline_coords(gap=0): + """ + Coordinates for vertical lines. + """ + x0 = (thick_gt + gap) / 2 + return { + "x": [-x0, -x0, x0, x0], + "y": [vline_y, r3, r3, vline_y], + } # %% fig = pygmt.Figure() @@ -206,19 +210,9 @@ def _red_line_coords(): fig.plot(data=_letter_g_coords(), fill=red, perspective=True) # fig.show() - # Upper vertical red line - # Space between red line and blue circle / hexagon - red_line_x, red_line_y = _red_line_coords() - fig.plot( - x=red_line_x, - y=red_line_y, - pen=f"{thick_gt + thick_comp}c,{color_bg}", - perspective=True, - ) - # fig.show() - # red line - fig.plot(x=red_line_x, y=red_line_y, pen=f"{thick_gt}c,{red}", perspective=True) - # fig.show() + # Upper vertical lines + fig.plot(data=_vline_coords(gap=thick_comp), fill=color_bg, perspective=True) + fig.plot(data=_vline_coords(), fill=red, perspective=True) # Letter M fig.plot(data=_letter_m_coords(), fill=red, perspective=True) From 8067fba2757cf6a6fb9dd347a0e8797d7e399c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 20 Apr 2026 13:16:06 +0200 Subject: [PATCH 295/379] Limit all compass lines to abs(r1) --- pygmt/src/pygmtlogo.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 616d7443e2f..60d2569329b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -30,9 +30,9 @@ def create_logo( # noqa: PLR0915 # Radii (make sure that r4-r5 == r2-r3) r0, r1, r2, r3, r4, r5 = size * np.array( - # [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] # old - # [1, 0.875, 0.58125, 0.4825, 0.4125, 0.31375] # exact - [1, 224/256, 150/256, 122/256, 106/256, 78/256] + # [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] # old + # [1, 0.875, 0.58125, 0.4825, 0.4125, 0.31375] # exact + [1, 224 / 256, 150 / 256, 122 / 256, 106 / 256, 78 / 256] ) # Pen thicknesses thick_shape = r0 - r1 # for shape @@ -148,9 +148,9 @@ def _compass_lines(): # Coordinates of vectors in the format of (x_start, y_start, x_end, y_end). return { "hline": [ - (-r0 * hex_factor, 0, -r3, 0), + (-r1 * hex_factor, 0, -r3, 0), # (-r5, 0, 0, 0), - (r3, 0, r0 * hex_factor, 0), + (r3, 0, r1 * hex_factor, 0), ], "diagonal": [ (-x1, x1, -x2, x2), # upper left @@ -188,6 +188,9 @@ def _vline_coords(gap=0): # White filled circle / hexagon for Earth fig.plot(fill=color_bg, **args_shape) # fig.show() + # Blue outlined circle / hexagon for Earth + fig.plot(pen=f"{thick_shape}c,{blue}", **args_shape) + # fig.show() compass_lines = _compass_lines() args_compass = { @@ -195,14 +198,8 @@ def _vline_coords(gap=0): "perspective": True, "style": "v0c+s", } - # Diagonal compass lines + # Compass lines fig.plot(data=compass_lines["diagonal"], **args_compass) - - # Blue outlined circle / hexagon for Earth - fig.plot(pen=f"{thick_shape}c,{blue}", **args_shape) - # fig.show() - - # Horizontal and vertical compass lines fig.plot(data=compass_lines["hline"], **args_compass) # fig.plot(data=compass_lines["vline1"], **args_compass) From c78c89c8de5dc16a15b397147501c0c3a07d7376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 20 Apr 2026 13:39:36 +0200 Subject: [PATCH 296/379] Remove unneeded variable --- pygmt/src/pygmtlogo.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 60d2569329b..4944e77bf9b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -74,14 +74,12 @@ def create_logo( # noqa: PLR0915 symbol = "c" # circle size_shape = r0 + r1 # radius size_shape_add = r0 - r1 - hex_factor = 1 vline_y = r0 arrow_y = -r0 case "hexagon": symbol = "h" # hexagon size_shape = (r0 - 0.3) * 2 # diameter size_shape_add = 0.6 - hex_factor = 0.98 vline_y = r1 * 0.99 arrow_y = -r1 * 0.99 @@ -148,9 +146,9 @@ def _compass_lines(): # Coordinates of vectors in the format of (x_start, y_start, x_end, y_end). return { "hline": [ - (-r1 * hex_factor, 0, -r3, 0), + (-r1, 0, -r3, 0), # (-r5, 0, 0, 0), - (r3, 0, r1 * hex_factor, 0), + (r3, 0, r1, 0), ], "diagonal": [ (-x1, x1, -x2, x2), # upper left From 718c7a2f1b5c6b49df57c7ead09a9e49dd76e0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 20 Apr 2026 13:41:58 +0200 Subject: [PATCH 297/379] Reorder code, improve comments --- pygmt/src/pygmtlogo.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4944e77bf9b..89e6b07e824 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -176,6 +176,7 @@ def _vline_coords(gap=0): region=region, projection=projection, perspective=perspective, frame="none" ) + # Earth - circle / hexagon args_shape = { "x": 0, "y": 0, @@ -183,24 +184,25 @@ def _vline_coords(gap=0): "perspective": True, "no_clip": True, # Needed for corners of hexagon shape } - # White filled circle / hexagon for Earth + # Shape fill fig.plot(fill=color_bg, **args_shape) # fig.show() - # Blue outlined circle / hexagon for Earth - fig.plot(pen=f"{thick_shape}c,{blue}", **args_shape) - # fig.show() - compass_lines = _compass_lines() + # Compass - yellow lines args_compass = { "pen": f"{thick_comp}c,{yellow}", "perspective": True, "style": "v0c+s", } - # Compass lines + compass_lines = _compass_lines() fig.plot(data=compass_lines["diagonal"], **args_compass) fig.plot(data=compass_lines["hline"], **args_compass) # fig.plot(data=compass_lines["vline1"], **args_compass) + # Shape outline + fig.plot(pen=f"{thick_shape}c,{blue}", **args_shape) + # fig.show() + # Letter G fig.plot(data=_letter_g_coords(), fill=red, perspective=True) # fig.show() From 20b5d7422d6a26a3909a7bb4a46f396f9ada8575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 20 Apr 2026 13:46:50 +0200 Subject: [PATCH 298/379] Add comment to explain plotting order --- pygmt/src/pygmtlogo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 89e6b07e824..62c24c0e27a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -198,8 +198,9 @@ def _vline_coords(gap=0): fig.plot(data=compass_lines["diagonal"], **args_compass) fig.plot(data=compass_lines["hline"], **args_compass) # fig.plot(data=compass_lines["vline1"], **args_compass) + # fig.show() - # Shape outline + # Shape outline (over ends of compass lines for hexagon shape) fig.plot(pen=f"{thick_shape}c,{blue}", **args_shape) # fig.show() From 537e750ba170813b948536985604962dcfa5491b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 20 Apr 2026 13:57:58 +0200 Subject: [PATCH 299/379] Improve plotting order Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 62c24c0e27a..03b7c8dc9a0 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -206,19 +206,14 @@ def _vline_coords(gap=0): # Letter G fig.plot(data=_letter_g_coords(), fill=red, perspective=True) - # fig.show() - - # Upper vertical lines - fig.plot(data=_vline_coords(gap=thick_comp), fill=color_bg, perspective=True) - fig.plot(data=_vline_coords(), fill=red, perspective=True) - # Letter M fig.plot(data=_letter_m_coords(), fill=red, perspective=True) - # fig.show() - # Letter T: red curved horizontal line fig.plot(data=_letter_t_coords(), fill=red, perspective=True) - # fig.show() + + # Upper vertical lines + fig.plot(data=_vline_coords(gap=thick_comp), fill=color_bg, perspective=True) + fig.plot(data=_vline_coords(), fill=red, perspective=True) # The arrow fig.plot( From 0515240868377bb70b50710ec6d81fc8d045cdbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 20 Apr 2026 17:25:43 +0200 Subject: [PATCH 300/379] Add debug parameter to add helping lines --- pygmt/src/pygmtlogo.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 03b7c8dc9a0..e8d2f398f8c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -16,6 +16,7 @@ def create_logo( # noqa: PLR0915 theme: Literal["light", "dark"] = "light", wordmark: Literal["horizontal", "vertical"] | bool = True, color: bool = True, + debug: bool = False, ): """ Create the PyGMT logo using PyGMT. @@ -253,18 +254,19 @@ def _vline_coords(gap=0): fig.text(text=text_wm, no_clip=True, **args_text_wm) # fig.show() - # # Helpful for implementing the logo; not included in the logo - # # Gridlines - # with pygmt.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") - # fig.plot(x=0, y=0, style=f"c{2 * (r2 + (r3 - r4))}c", pen="0.3p,gray30,2_2") - # # Lines for letter M - # fig.hlines(y=[r4, r5], pen="0.3p,gray30,2_2") - # fig.vlines(x=r4, pen="0.3p,gray30,2_2") - # fig.vlines(x=(thick_gap + r4) / 2, pen="0.3p,gray30,2_2") + # Helpful for implementing the logo; not included in the logo + if debug: + # Gridlines + with pygmt.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") + fig.plot(x=0, y=0, style=f"c{2 * (r2 + (r3 - r4))}c", pen="0.3p,gray30,2_2") + # Lines for letter M + fig.hlines(y=[r4, r5], pen="0.3p,gray30,2_2") + fig.vlines(x=r4, pen="0.3p,gray30,2_2") + fig.vlines(x=(thick_gap + r4) / 2, pen="0.3p,gray30,2_2") # fig.show() fig_name_logo = "pygmt_logo" From 89bd0afeb57128b7196c5f2960d4031dbc084af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 20 Apr 2026 17:32:59 +0200 Subject: [PATCH 301/379] TEST: Adjustments for hexagon shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e8d2f398f8c..b5b88e9ff0a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -79,10 +79,10 @@ def create_logo( # noqa: PLR0915 arrow_y = -r0 case "hexagon": symbol = "h" # hexagon - size_shape = (r0 - 0.3) * 2 # diameter + size_shape = (r0 + 0.3) * 2 # diameter size_shape_add = 0.6 - vline_y = r1 * 0.99 - arrow_y = -r1 * 0.99 + vline_y = r0 * 0.99 + arrow_y = -r0 * 0.99 # Define wordmark font = "AvantGarde-Book" @@ -143,13 +143,13 @@ def _compass_lines(): Plot vertical line on top of letters G and M again at the end. """ sqrt2 = np.sqrt(2) / 2 - x1, x2, x3 = r1 * sqrt2, r3 * sqrt2, (r2 + (r3 - r4)) * sqrt2 + 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 { "hline": [ - (-r1, 0, -r3, 0), + (-r0, 0, -r3, 0), # (-r5, 0, 0, 0), - (r3, 0, r1, 0), + (r3, 0, r0, 0), ], "diagonal": [ (-x1, x1, -x2, x2), # upper left From 7f8f99b48200a1d1c1562a3c3814ede3bf7a0183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 20 Apr 2026 17:47:38 +0200 Subject: [PATCH 302/379] Remove old code parts --- pygmt/src/pygmtlogo.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index b5b88e9ff0a..6b3be37577e 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -31,8 +31,6 @@ def create_logo( # noqa: PLR0915 # Radii (make sure that r4-r5 == r2-r3) r0, r1, r2, r3, r4, r5 = size * np.array( - # [1, 0.875, 0.58125, 0.4625, 0.4125, 0.29375] # old - # [1, 0.875, 0.58125, 0.4825, 0.4125, 0.31375] # exact [1, 224 / 256, 150 / 256, 122 / 256, 106 / 256, 78 / 256] ) # Pen thicknesses @@ -146,19 +144,13 @@ def _compass_lines(): 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 { - "hline": [ - (-r0, 0, -r3, 0), - # (-r5, 0, 0, 0), - (r3, 0, r0, 0), - ], + "hline": [(-r0, 0, -r3, 0), (r3, 0, r0, 0)], "diagonal": [ (-x1, x1, -x2, x2), # upper left (-x1, -x1, -x2, -x2), # lower left (x1, x1, x3, x3), # upper right (x1, -x1, x2, -x2), # lower right ], - "vline1": [(0, -r3, 0, 0)], - "vline2": [(0, -thick_shape / 2, 0, r3)], } def _vline_coords(gap=0): @@ -198,7 +190,6 @@ def _vline_coords(gap=0): compass_lines = _compass_lines() fig.plot(data=compass_lines["diagonal"], **args_compass) fig.plot(data=compass_lines["hline"], **args_compass) - # fig.plot(data=compass_lines["vline1"], **args_compass) # fig.show() # Shape outline (over ends of compass lines for hexagon shape) @@ -232,10 +223,6 @@ def _vline_coords(gap=0): ) # fig.show() - # Vertical compass line above letters G and M. - # fig.plot(data=compass_lines["vline2"], **args_compass) - # fig.show() - # Outline around the shape for black and white color with dark theme if not color and theme == "dark": fig.plot( From 97d1af1331bc7c453aacbdeb1b94e90cedf0d458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 20 Apr 2026 17:51:39 +0200 Subject: [PATCH 303/379] Use max line length Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6b3be37577e..c7cdc8e872d 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -158,10 +158,7 @@ def _vline_coords(gap=0): Coordinates for vertical lines. """ x0 = (thick_gt + gap) / 2 - return { - "x": [-x0, -x0, x0, x0], - "y": [vline_y, r3, r3, vline_y], - } + return {"x": [-x0, -x0, x0, x0], "y": [vline_y, r3, r3, vline_y]} # %% fig = pygmt.Figure() From 8df1bba9b0664f486bcf2b8fab11382d56c30b29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 20 Apr 2026 17:52:24 +0200 Subject: [PATCH 304/379] Plot vertical help lines in one plot call Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index c7cdc8e872d..fafbe734763 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -249,8 +249,7 @@ def _vline_coords(gap=0): fig.plot(x=0, y=0, style=f"c{2 * (r2 + (r3 - r4))}c", pen="0.3p,gray30,2_2") # Lines for letter M fig.hlines(y=[r4, r5], pen="0.3p,gray30,2_2") - fig.vlines(x=r4, pen="0.3p,gray30,2_2") - fig.vlines(x=(thick_gap + r4) / 2, pen="0.3p,gray30,2_2") + fig.vlines(x=[r4, (thick_gap + r4) / 2], pen="0.3p,gray30,2_2") # fig.show() fig_name_logo = "pygmt_logo" From a27a6b49a0cef2732890335c9ecea33e107bc3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:18:22 +0200 Subject: [PATCH 305/379] Sorten descripition of function create_logo Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index fafbe734763..645c85f02ba 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -20,8 +20,6 @@ def create_logo( # noqa: PLR0915 ): """ Create the PyGMT logo using PyGMT. - The design of the logo is kindly provided by `@sfrooti `_ - and consists of a visual and the wordmark "PyGMT". """ # Helpful definitions From ca0eb165d5da600b6fb2027eaa2e29781e4292b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:19:19 +0200 Subject: [PATCH 306/379] Remove unneeded comment due to remove of inner compass lines Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 645c85f02ba..c1a3207ee17 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -136,7 +136,6 @@ def _letter_t_coords(): def _compass_lines(): """ Coordinates of compass lines. - Plot vertical line on top of letters G and M again at the end. """ sqrt2 = np.sqrt(2) / 2 x1, x2, x3 = r0 * sqrt2, r3 * sqrt2, (r2 + (r3 - r4)) * sqrt2 From 7d965029bd5c1419457e8c1e0cc03ada87b040ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:19:55 +0200 Subject: [PATCH 307/379] Remove seperator Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index c1a3207ee17..eeba827b429 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -157,7 +157,6 @@ def _vline_coords(gap=0): x0 = (thick_gt + gap) / 2 return {"x": [-x0, -x0, x0, x0], "y": [vline_y, r3, r3, vline_y]} - # %% fig = pygmt.Figure() fig.basemap( region=region, projection=projection, perspective=perspective, frame="none" From 8fa1dee4eb3897bd5a4facb1800a20c2914e242f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:21:17 +0200 Subject: [PATCH 308/379] Set coordinates in plot call for shape Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index eeba827b429..acd348985bc 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -164,14 +164,12 @@ def _vline_coords(gap=0): # Earth - circle / hexagon args_shape = { - "x": 0, - "y": 0, "style": f"{symbol}{size_shape}c", "perspective": True, "no_clip": True, # Needed for corners of hexagon shape } # Shape fill - fig.plot(fill=color_bg, **args_shape) + fig.plot(x=0, y=0, fill=color_bg, **args_shape) # fig.show() # Compass - yellow lines @@ -186,7 +184,7 @@ def _vline_coords(gap=0): # fig.show() # Shape outline (over ends of compass lines for hexagon shape) - fig.plot(pen=f"{thick_shape}c,{blue}", **args_shape) + fig.plot(x=0, y=0, pen=f"{thick_shape}c,{blue}", **args_shape) # fig.show() # Letter G From b120249fe010c21e60ae6a22621f28d7cd410c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:22:13 +0200 Subject: [PATCH 309/379] Remove fig.show Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index acd348985bc..08d1c1c3820 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -170,7 +170,6 @@ def _vline_coords(gap=0): } # Shape fill fig.plot(x=0, y=0, fill=color_bg, **args_shape) - # fig.show() # Compass - yellow lines args_compass = { From ce173ec593f667a82c6805049ab19f582db5e9cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:24:31 +0200 Subject: [PATCH 310/379] Make create_logo a private function Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 08d1c1c3820..e6bfa39f06b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -10,8 +10,10 @@ import numpy as np import pygmt +__doctest_skip__ = ["pygmtlogo"] -def create_logo( # noqa: PLR0915 + +def _create_logo( # noqa: PLR0915 shape: Literal["circle", "hexagon"] = "circle", theme: Literal["light", "dark"] = "light", wordmark: Literal["horizontal", "vertical"] | bool = True, @@ -292,7 +294,7 @@ def pygmtlogo( # noqa: PLR0913 # ----------------------------------------------------------------------------- # Create logo file # ----------------------------------------------------------------------------- - fig_name_logo = create_logo( + fig_name_logo = _create_logo( color=color, theme=theme, shape=shape, wordmark=wordmark ) From 409ab84e23739c2b2586ad15eb1e3235482d9eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:26:34 +0200 Subject: [PATCH 311/379] Allow setting hight and width for adding logo to the plot Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e6bfa39f06b..022429b2d6b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -260,6 +260,8 @@ def pygmtlogo( # noqa: PLR0913 shape="circle", wordmark=True, position=None, # -> Use position parameter of Figure.image + width=None, # -> Use width parameter of Figure.image + height=None, # -> Use height parameter of Figure.image box=None, # -> Use box parameter of Figure.image projection=None, region=None, @@ -304,6 +306,8 @@ def pygmtlogo( # noqa: PLR0913 self.image( imagefile=f"{fig_name_logo}.eps", position=position, + width=width, + height=height, box=box, projection=projection, region=region, From 894a51c7962aa6792d40d99e068a518843306983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:27:21 +0200 Subject: [PATCH 312/379] Add inline example Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 022429b2d6b..a677d5dbb4a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -291,6 +291,21 @@ def pygmtlogo( # noqa: PLR0913 color Set to ``True`` to use colors referring to Python (blue and yellow) and GMT (red) [Default]. For ``False``, the logo is drawn in black and white. + + Examples + -------- + >>> import pygmt + >>> fig = pygmt.Figure() + >>> fig.basemap(region=[-90, -70, 0, 20], projection="M10c", frame=True) + >>> fig.pygmtlogo( + ... shape="circle", + ... theme="light", + ... wordmark="horizontal", + ... color=True, + ... position="BR", + ... height="1c", + ... ) + >>> fig.show() """ # ----------------------------------------------------------------------------- From fea12d49ee4a3de96a93dab25dce4b31b68d2c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 21 Apr 2026 09:34:41 +0200 Subject: [PATCH 313/379] Add perspective for helping lines --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index a677d5dbb4a..e6908e40659 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -243,8 +243,8 @@ def _vline_coords(gap=0): fig.plot(x=0, y=0, style=f"c{2 * r}c", pen="0.3p,gray30") fig.plot(x=0, y=0, style=f"c{2 * (r2 + (r3 - r4))}c", pen="0.3p,gray30,2_2") # Lines for letter M - fig.hlines(y=[r4, r5], pen="0.3p,gray30,2_2") - fig.vlines(x=[r4, (thick_gap + r4) / 2], pen="0.3p,gray30,2_2") + fig.hlines(y=[r4, r5], pen="0.3p,gray30,2_2", perspective=True) + fig.vlines(x=[r4, (thick_gap + r4) / 2], pen="0.3p,gray30,2_2", perspective=True) # fig.show() fig_name_logo = "pygmt_logo" From c93c4bf09ffd1992c68be77106c0356cbe14383f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 21 Apr 2026 09:49:02 +0200 Subject: [PATCH 314/379] Limit helping lines to fit into frame even after rotation --- pygmt/src/pygmtlogo.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e6908e40659..b8aaa171c01 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -241,10 +241,16 @@ def _vline_coords(gap=0): # 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") - fig.plot(x=0, y=0, style=f"c{2 * (r2 + (r3 - r4))}c", pen="0.3p,gray30,2_2") + 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], pen="0.3p,gray30,2_2", perspective=True) - fig.vlines(x=[r4, (thick_gap + r4) / 2], pen="0.3p,gray30,2_2", perspective=True) + 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.show() fig_name_logo = "pygmt_logo" From a0a38a4128adf53d5a696fa88f4e0b327398a021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 11:36:08 +0200 Subject: [PATCH 315/379] Shorten variable name to fit into one line Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index b8aaa171c01..657531b7a82 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -27,7 +27,7 @@ def _create_logo( # noqa: PLR0915 # Helpful definitions size = 4 region = [-size, size] * 2 - projection = "x1c" + proj = "x1c" # Radii (make sure that r4-r5 == r2-r3) r0, r1, r2, r3, r4, r5 = size * np.array( @@ -160,9 +160,7 @@ def _vline_coords(gap=0): return {"x": [-x0, -x0, x0, x0], "y": [vline_y, r3, r3, vline_y]} fig = pygmt.Figure() - fig.basemap( - region=region, projection=projection, perspective=perspective, frame="none" - ) + fig.basemap(region=region, projection=proj, perspective=perspective, frame="none") # Earth - circle / hexagon args_shape = { From ab997e04b26a2a57fc00ce4f88ba5694424002f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 11:37:56 +0200 Subject: [PATCH 316/379] Try if code fits in one line Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 657531b7a82..fc48aef849c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -243,12 +243,7 @@ def _vline_coords(gap=0): 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.vlines(x=[r4, (thick_gap + r4) / 2], ymax=3, pen=pen, perspective=True) # fig.show() fig_name_logo = "pygmt_logo" From cd3bb6265dae690f8877aa5958920fba9fc83d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 11:38:39 +0200 Subject: [PATCH 317/379] Try if code fits in one line Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index fc48aef849c..3f117798e8b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -30,9 +30,7 @@ def _create_logo( # noqa: PLR0915 proj = "x1c" # Radii (make sure that r4-r5 == r2-r3) - r0, r1, r2, r3, r4, r5 = size * np.array( - [1, 224 / 256, 150 / 256, 122 / 256, 106 / 256, 78 / 256] - ) + r0, r1, r2, r3, r4, r5 = size * np.array([256, 224, 150, 122, 106, 78]) / 256 # Pen thicknesses thick_shape = r0 - r1 # for shape thick_gt = r4 - r5 # for letters G and T From 6ad9690833c90022470c16a64f4c5ce46afe627c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 11:39:54 +0200 Subject: [PATCH 318/379] Combine compass lines into one plot call Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 3f117798e8b..18dd7af903e 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -140,15 +140,14 @@ def _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 { - "hline": [(-r0, 0, -r3, 0), (r3, 0, r0, 0)], - "diagonal": [ - (-x1, x1, -x2, x2), # upper left - (-x1, -x1, -x2, -x2), # lower left - (x1, x1, x3, x3), # upper right - (x1, -x1, x2, -x2), # lower right - ], - } + return [ + (-r0, 0, -r3, 0), # left horizontal + (r3, 0, r0, 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(gap=0): """ @@ -169,16 +168,13 @@ def _vline_coords(gap=0): # Shape fill fig.plot(x=0, y=0, fill=color_bg, **args_shape) - # Compass - yellow lines - args_compass = { - "pen": f"{thick_comp}c,{yellow}", - "perspective": True, - "style": "v0c+s", - } - compass_lines = _compass_lines() - fig.plot(data=compass_lines["diagonal"], **args_compass) - fig.plot(data=compass_lines["hline"], **args_compass) - # fig.show() + # Compass lines + fig.plot( + data=_compass_lines(), + pen=f"{thick_comp}c,{yellow}", + style="v0c+s", + perspective=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) From 4a522c61ae7254feb745aca13eafb7f8bfe644ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 12:01:21 +0200 Subject: [PATCH 319/379] TEST: Adjustments for hexagon shape size of r0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 18dd7af903e..20c95af8815 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -75,10 +75,10 @@ def _create_logo( # noqa: PLR0915 arrow_y = -r0 case "hexagon": symbol = "h" # hexagon - size_shape = (r0 + 0.3) * 2 # diameter + size_shape = r0 * 2 # diameter size_shape_add = 0.6 - vline_y = r0 * 0.99 - arrow_y = -r0 * 0.99 + vline_y = r0 * 0.93 + arrow_y = -r0 * 0.93 # Define wordmark font = "AvantGarde-Book" @@ -138,7 +138,7 @@ def _compass_lines(): Coordinates of compass lines. """ sqrt2 = np.sqrt(2) / 2 - x1, x2, x3 = r0 * sqrt2, r3 * sqrt2, (r2 + (r3 - r4)) * sqrt2 + x1, x2, x3 = r1 * sqrt2, r3 * sqrt2, (r2 + (r3 - r4)) * sqrt2 # Coordinates of vectors in the format of (x_start, y_start, x_end, y_end). return [ (-r0, 0, -r3, 0), # left horizontal From 5989fadce18c7b6a3d7420d3d45ff8859886e9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 12:37:52 +0200 Subject: [PATCH 320/379] Calculate curved top line of letter T based on South at 270 deg Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 20c95af8815..8f9827fac11 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -125,10 +125,10 @@ def _letter_m_coords(): def _letter_t_coords(): """Coordinates of the top curved horizontal line for letter T.""" - outer_angles = np.deg2rad(np.arange(150, 210, 0.5)) + outer_angles = np.deg2rad(np.arange(240, 300, 0.5)) inner_angles = outer_angles[::-1] - t_x = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) - t_y = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) + t_x = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) + t_y = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) # 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]} From 8f9f8d079bcda2b4ba133e4f88caf0bbdcde1889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 12:41:42 +0200 Subject: [PATCH 321/379] Use 'thick_shape" for drawing outline for black-white dark case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 8f9827fac11..fb58a5f962d 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -66,19 +66,17 @@ def _create_logo( # noqa: PLR0915 color_gmt = color_light # Define shape - match shape: - case "circle": - symbol = "c" # circle - size_shape = r0 + r1 # radius - size_shape_add = r0 - r1 - vline_y = r0 - arrow_y = -r0 - case "hexagon": - symbol = "h" # hexagon - size_shape = r0 * 2 # diameter - size_shape_add = 0.6 - vline_y = r0 * 0.93 - arrow_y = -r0 * 0.93 + match shape: + case "circle": + symbol = "c" + size_shape = r0 + r1 + vline_y = r0 + arrow_y = -r0 + case "hexagon": + symbol = "h" + size_shape = r0 * 2 + vline_y = r0 * 0.93 + arrow_y = -r0 * 0.93 # Define wordmark font = "AvantGarde-Book" @@ -212,7 +210,7 @@ def _vline_coords(gap=0): fig.plot( x=0, y=0, - style=f"{symbol}{size_shape + size_shape_add}c", + style=f"{symbol}{size_shape + thick_shape}c", pen=f"1p,{color_dark}", perspective=True, no_clip=True, From 23b3e39447a720b4a5fddc80175cab0950c2d060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 13:56:52 +0200 Subject: [PATCH 322/379] TEST: Adjustments for hexagon shape size of r0+0.35 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 632 +++++++++++++++++++++-------------------- 1 file changed, 317 insertions(+), 315 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index fb58a5f962d..57b7fcee380 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -1,325 +1,327 @@ -""" -pygmtlogo - Create and plot the PyGMT logo. -The design of the logo is kindly provided by `@sfrooti `_ -and consists of a visual and the wordmark "PyGMT". -""" - -from pathlib import Path -from typing import Literal - -import numpy as np -import pygmt - -__doctest_skip__ = ["pygmtlogo"] - - -def _create_logo( # noqa: PLR0915 - shape: Literal["circle", "hexagon"] = "circle", - theme: Literal["light", "dark"] = "light", - wordmark: Literal["horizontal", "vertical"] | bool = True, - color: bool = True, - debug: bool = False, -): - """ - Create the PyGMT logo using PyGMT. - """ - - # Helpful definitions - size = 4 - region = [-size, size] * 2 - proj = "x1c" - - # Radii (make sure that r4-r5 == r2-r3) - r0, r1, r2, r3, r4, r5 = size * np.array([256, 224, 150, 122, 106, 78]) / 256 - # 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_comp / 4) * 3 - - # Rotation around z (vertical) axis placed in the center - # Has to be applied to each plotting command, up on second call set to True - perspective = "30+w0/0" # by 30 degrees counter-clockwise - - # 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 +""" +pygmtlogo - Create and plot the PyGMT logo. +The design of the logo is kindly provided by `@sfrooti `_ +and consists of a visual and the wordmark "PyGMT". +""" + +from pathlib import Path +from typing import Literal + +import numpy as np +import pygmt + +__doctest_skip__ = ["pygmtlogo"] + + +def _create_logo( # noqa: PLR0915 + shape: Literal["circle", "hexagon"] = "circle", + theme: Literal["light", "dark"] = "light", + wordmark: Literal["horizontal", "vertical"] | bool = True, + color: bool = True, + debug: bool = False, +): + """ + Create the PyGMT logo using PyGMT. + """ + + # Helpful definitions + size = 4 + region = [-size, size] * 2 + proj = "x1c" + + # Radii (make sure that r4-r5 == r2-r3) + r0, r1, r2, r3, r4, r5 = size * np.array([256, 224, 150, 122, 106, 78]) / 256 + # 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_comp / 4) * 3 + + # Rotation around z (vertical) axis placed in the center + # Has to be applied to each plotting command, up on second call set to True + perspective = "30+w0/0" # by 30 degrees counter-clockwise + + # 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 vline_y = r0 arrow_y = -r0 case "hexagon": symbol = "h" - size_shape = r0 * 2 + size_shape = (r0 + 0.35) * 2 + hex_factor = 1.1 vline_y = r0 * 0.93 arrow_y = -r0 * 0.93 - - # 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 True | "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 of the top curved horizontal line for letter T.""" - outer_angles = np.deg2rad(np.arange(240, 300, 0.5)) - inner_angles = outer_angles[::-1] - t_x = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) - t_y = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) - # 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 _compass_lines(): - """ - Coordinates of compass lines. - """ - sqrt2 = np.sqrt(2) / 2 - x1, x2, x3 = r1 * sqrt2, r3 * sqrt2, (r2 + (r3 - r4)) * sqrt2 - # Coordinates of vectors in the format of (x_start, y_start, x_end, y_end). - return [ - (-r0, 0, -r3, 0), # left horizontal - (r3, 0, r0, 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(gap=0): - """ - Coordinates for vertical lines. - """ - x0 = (thick_gt + gap) / 2 - return {"x": [-x0, -x0, x0, x0], "y": [vline_y, r3, r3, vline_y]} - - fig = pygmt.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, - ) - - # Shape outline (over ends of compass lines for hexagon shape) - fig.plot(x=0, y=0, pen=f"{thick_shape}c,{blue}", **args_shape) - # fig.show() - - # Letter G - fig.plot(data=_letter_g_coords(), fill=red, perspective=True) - # Letter M - fig.plot(data=_letter_m_coords(), fill=red, perspective=True) - # Letter T: red curved horizontal line - fig.plot(data=_letter_t_coords(), fill=red, perspective=True) - - # Upper vertical lines - fig.plot(data=_vline_coords(gap=thick_comp), fill=color_bg, perspective=True) - fig.plot(data=_vline_coords(), fill=red, perspective=True) - - # The arrow - fig.plot( - data=[[0, -r2, 0, arrow_y - thick_comp]], - pen=color_bg, - style=f"v{thick_shape + thick_comp * 2}c+s+e+h0+a60+g{color_bg}", - perspective=True, - ) - # fig.show() - fig.plot( - data=[[0, -r3, 0, arrow_y]], - pen=f"{thick_gt}c,{red}", - style=f"v{thick_shape + thick_comp}c+s+e+h0+a60+g{red}", - perspective=True, - ) - # fig.show() - - # 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, - ) - # fig.show() - - # Add wordmark "PyGMT" - if wordmark: - text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" - fig.text(text=text_wm, no_clip=True, **args_text_wm) - # fig.show() - - # Helpful for implementing the logo; not included in the logo - if debug: - # Gridlines - with pygmt.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.show() - fig_name_logo = "pygmt_logo" - fig.savefig(fname=f"{fig_name_logo}.eps") - - return fig_name_logo - - -def pygmtlogo( # noqa: PLR0913 - self, - color=True, - theme="light", - shape="circle", - wordmark=True, - position=None, # -> Use position parameter of Figure.image - width=None, # -> Use width parameter of Figure.image - height=None, # -> Use height parameter of Figure.image - box=None, # -> Use box parameter of Figure.image - projection=None, - region=None, - verbose=None, - panel=None, - transparency=None, -): - """ - Plot the PyGMT logo. - The design of the logo is kindly provided by `@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 [gray20] background). - wordmark - Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set - to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the - visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and - ``False`` to add no wordmark. - color - Set to ``True`` to use colors referring to Python (blue and yellow) and GMT - (red) [Default]. For ``False``, the logo is drawn in black and white. - - Examples - -------- - >>> import pygmt - >>> fig = pygmt.Figure() - >>> fig.basemap(region=[-90, -70, 0, 20], projection="M10c", frame=True) - >>> fig.pygmtlogo( - ... shape="circle", - ... theme="light", - ... wordmark="horizontal", - ... color=True, - ... position="BR", - ... height="1c", - ... ) - >>> fig.show() - """ - - # ----------------------------------------------------------------------------- - # Create logo file - # ----------------------------------------------------------------------------- - fig_name_logo = _create_logo( - color=color, theme=theme, shape=shape, wordmark=wordmark - ) - - # ----------------------------------------------------------------------------- - # Add to existing Figure instance - # ----------------------------------------------------------------------------- - self.image( - imagefile=f"{fig_name_logo}.eps", - position=position, - width=width, - height=height, - box=box, - projection=projection, - region=region, - verbose=verbose, - panel=panel, - transparency=transparency, - ) - - Path.unlink(f"{fig_name_logo}.eps") + + # 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 True | "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 of the top curved horizontal line for letter T.""" + outer_angles = np.deg2rad(np.arange(240, 300, 0.5)) + inner_angles = outer_angles[::-1] + t_x = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) + t_y = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) + # 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 _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(gap=0): + """ + Coordinates for vertical lines. + """ + x0 = (thick_gt + gap) / 2 + return {"x": [-x0, -x0, x0, x0], "y": [vline_y, r3, r3, vline_y]} + + fig = pygmt.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, + ) + + # Shape outline (over ends of compass lines for hexagon shape) + fig.plot(x=0, y=0, pen=f"{thick_shape}c,{blue}", **args_shape) + # fig.show() + + # Letter G + fig.plot(data=_letter_g_coords(), fill=red, perspective=True) + # Letter M + fig.plot(data=_letter_m_coords(), fill=red, perspective=True) + # Letter T: red curved horizontal line + fig.plot(data=_letter_t_coords(), fill=red, perspective=True) + + # Upper vertical lines + fig.plot(data=_vline_coords(gap=thick_comp), fill=color_bg, perspective=True) + fig.plot(data=_vline_coords(), fill=red, perspective=True) + + # The arrow + fig.plot( + data=[[0, -r2, 0, arrow_y - thick_comp]], + pen=color_bg, + style=f"v{thick_shape + thick_comp * 2}c+s+e+h0+a60+g{color_bg}", + perspective=True, + ) + # fig.show() + fig.plot( + data=[[0, -r3, 0, arrow_y]], + pen=f"{thick_gt}c,{red}", + style=f"v{thick_shape + thick_comp}c+s+e+h0+a60+g{red}", + perspective=True, + ) + # fig.show() + + # 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, + ) + # fig.show() + + # Add wordmark "PyGMT" + if wordmark: + text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" + fig.text(text=text_wm, no_clip=True, **args_text_wm) + # fig.show() + + # Helpful for implementing the logo; not included in the logo + if debug: + # Gridlines + with pygmt.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.show() + fig_name_logo = "pygmt_logo" + fig.savefig(fname=f"{fig_name_logo}.eps") + + return fig_name_logo + + +def pygmtlogo( # noqa: PLR0913 + self, + color=True, + theme="light", + shape="circle", + wordmark=True, + position=None, # -> Use position parameter of Figure.image + width=None, # -> Use width parameter of Figure.image + height=None, # -> Use height parameter of Figure.image + box=None, # -> Use box parameter of Figure.image + projection=None, + region=None, + verbose=None, + panel=None, + transparency=None, +): + """ + Plot the PyGMT logo. + The design of the logo is kindly provided by `@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 [gray20] background). + wordmark + Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set + to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the + visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and + ``False`` to add no wordmark. + color + Set to ``True`` to use colors referring to Python (blue and yellow) and GMT + (red) [Default]. For ``False``, the logo is drawn in black and white. + + Examples + -------- + >>> import pygmt + >>> fig = pygmt.Figure() + >>> fig.basemap(region=[-90, -70, 0, 20], projection="M10c", frame=True) + >>> fig.pygmtlogo( + ... shape="circle", + ... theme="light", + ... wordmark="horizontal", + ... color=True, + ... position="BR", + ... height="1c", + ... ) + >>> fig.show() + """ + + # ----------------------------------------------------------------------------- + # Create logo file + # ----------------------------------------------------------------------------- + fig_name_logo = _create_logo( + color=color, theme=theme, shape=shape, wordmark=wordmark + ) + + # ----------------------------------------------------------------------------- + # Add to existing Figure instance + # ----------------------------------------------------------------------------- + self.image( + imagefile=f"{fig_name_logo}.eps", + position=position, + width=width, + height=height, + box=box, + projection=projection, + region=region, + verbose=verbose, + panel=panel, + transparency=transparency, + ) + + Path.unlink(f"{fig_name_logo}.eps") From d60a057113165165dd19a7598ee920b55ced9d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 21 Apr 2026 14:19:12 +0200 Subject: [PATCH 323/379] Define letter T entierly via a polygon Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 658 +++++++++++++++++++++-------------------- 1 file changed, 331 insertions(+), 327 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 57b7fcee380..26cc73d1e02 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -1,327 +1,331 @@ -""" -pygmtlogo - Create and plot the PyGMT logo. -The design of the logo is kindly provided by `@sfrooti `_ -and consists of a visual and the wordmark "PyGMT". -""" - -from pathlib import Path -from typing import Literal - -import numpy as np -import pygmt - -__doctest_skip__ = ["pygmtlogo"] - - -def _create_logo( # noqa: PLR0915 - shape: Literal["circle", "hexagon"] = "circle", - theme: Literal["light", "dark"] = "light", - wordmark: Literal["horizontal", "vertical"] | bool = True, - color: bool = True, - debug: bool = False, -): - """ - Create the PyGMT logo using PyGMT. - """ - - # Helpful definitions - size = 4 - region = [-size, size] * 2 - proj = "x1c" - - # Radii (make sure that r4-r5 == r2-r3) - r0, r1, r2, r3, r4, r5 = size * np.array([256, 224, 150, 122, 106, 78]) / 256 - # 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_comp / 4) * 3 - - # Rotation around z (vertical) axis placed in the center - # Has to be applied to each plotting command, up on second call set to True - perspective = "30+w0/0" # by 30 degrees counter-clockwise - - # 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 - vline_y = r0 - arrow_y = -r0 - case "hexagon": - symbol = "h" - size_shape = (r0 + 0.35) * 2 - hex_factor = 1.1 - vline_y = r0 * 0.93 - arrow_y = -r0 * 0.93 - - # 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 True | "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 of the top curved horizontal line for letter T.""" - outer_angles = np.deg2rad(np.arange(240, 300, 0.5)) - inner_angles = outer_angles[::-1] - t_x = np.concatenate([r2 * np.cos(outer_angles), r3 * np.cos(inner_angles)]) - t_y = np.concatenate([r2 * np.sin(outer_angles), r3 * np.sin(inner_angles)]) - # 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 _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(gap=0): - """ - Coordinates for vertical lines. - """ - x0 = (thick_gt + gap) / 2 - return {"x": [-x0, -x0, x0, x0], "y": [vline_y, r3, r3, vline_y]} - - fig = pygmt.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, - ) - - # Shape outline (over ends of compass lines for hexagon shape) - fig.plot(x=0, y=0, pen=f"{thick_shape}c,{blue}", **args_shape) - # fig.show() - - # Letter G - fig.plot(data=_letter_g_coords(), fill=red, perspective=True) - # Letter M - fig.plot(data=_letter_m_coords(), fill=red, perspective=True) - # Letter T: red curved horizontal line - fig.plot(data=_letter_t_coords(), fill=red, perspective=True) - - # Upper vertical lines - fig.plot(data=_vline_coords(gap=thick_comp), fill=color_bg, perspective=True) - fig.plot(data=_vline_coords(), fill=red, perspective=True) - - # The arrow - fig.plot( - data=[[0, -r2, 0, arrow_y - thick_comp]], - pen=color_bg, - style=f"v{thick_shape + thick_comp * 2}c+s+e+h0+a60+g{color_bg}", - perspective=True, - ) - # fig.show() - fig.plot( - data=[[0, -r3, 0, arrow_y]], - pen=f"{thick_gt}c,{red}", - style=f"v{thick_shape + thick_comp}c+s+e+h0+a60+g{red}", - perspective=True, - ) - # fig.show() - - # 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, - ) - # fig.show() - - # Add wordmark "PyGMT" - if wordmark: - text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" - fig.text(text=text_wm, no_clip=True, **args_text_wm) - # fig.show() - - # Helpful for implementing the logo; not included in the logo - if debug: - # Gridlines - with pygmt.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.show() - fig_name_logo = "pygmt_logo" - fig.savefig(fname=f"{fig_name_logo}.eps") - - return fig_name_logo - - -def pygmtlogo( # noqa: PLR0913 - self, - color=True, - theme="light", - shape="circle", - wordmark=True, - position=None, # -> Use position parameter of Figure.image - width=None, # -> Use width parameter of Figure.image - height=None, # -> Use height parameter of Figure.image - box=None, # -> Use box parameter of Figure.image - projection=None, - region=None, - verbose=None, - panel=None, - transparency=None, -): - """ - Plot the PyGMT logo. - The design of the logo is kindly provided by `@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 [gray20] background). - wordmark - Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set - to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the - visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and - ``False`` to add no wordmark. - color - Set to ``True`` to use colors referring to Python (blue and yellow) and GMT - (red) [Default]. For ``False``, the logo is drawn in black and white. - - Examples - -------- - >>> import pygmt - >>> fig = pygmt.Figure() - >>> fig.basemap(region=[-90, -70, 0, 20], projection="M10c", frame=True) - >>> fig.pygmtlogo( - ... shape="circle", - ... theme="light", - ... wordmark="horizontal", - ... color=True, - ... position="BR", - ... height="1c", - ... ) - >>> fig.show() - """ - - # ----------------------------------------------------------------------------- - # Create logo file - # ----------------------------------------------------------------------------- - fig_name_logo = _create_logo( - color=color, theme=theme, shape=shape, wordmark=wordmark - ) - - # ----------------------------------------------------------------------------- - # Add to existing Figure instance - # ----------------------------------------------------------------------------- - self.image( - imagefile=f"{fig_name_logo}.eps", - position=position, - width=width, - height=height, - box=box, - projection=projection, - region=region, - verbose=verbose, - panel=panel, - transparency=transparency, - ) - - Path.unlink(f"{fig_name_logo}.eps") +""" +pygmtlogo - Create and plot the PyGMT logo. +The design of the logo is kindly provided by `@sfrooti `_ +and consists of a visual and the wordmark "PyGMT". +""" + +from pathlib import Path +from typing import Literal + +import numpy as np +import pygmt + +__doctest_skip__ = ["pygmtlogo"] + + +def _create_logo( # noqa: PLR0915 + shape: Literal["circle", "hexagon"] = "circle", + theme: Literal["light", "dark"] = "light", + wordmark: Literal["horizontal", "vertical"] | bool = True, + color: bool = True, + debug: bool = False, +): + """ + Create the PyGMT logo using PyGMT. + """ + + # Helpful definitions + size = 4 + region = [-size, size] * 2 + proj = "x1c" + + # Radii (make sure that r4-r5 == r2-r3) + r0, r1, r2, r3, r4, r5 = size * np.array([256, 224, 150, 122, 106, 78]) / 256 + # 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_comp / 4) * 3 + + # Rotation around z (vertical) axis placed in the center + # Has to be applied to each plotting command, up on second call set to True + perspective = "30+w0/0" # by 30 degrees counter-clockwise + + # 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 + vline_y = r0 + case "hexagon": + symbol = "h" + size_shape = (r0 + 0.35) * 2 + hex_factor = 1.1 + vline_y = r0 * 0.93 + + # 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 True | "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 of the top curved horizontal line 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 = 2 * 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 = 2 * x0 * np.sqrt(3) + arrow_x = [-x0 * 3.0, -x0, x0, x0 * 3.0] + arrow_y = [-r0 + y0, -r0, -r0, -r0 + y0] + 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(gap=0): + """ + Coordinates for vertical lines. + """ + x0 = (thick_gt + gap) / 2 + return {"x": [-x0, -x0, x0, x0], "y": [vline_y, r3, r3, vline_y]} + + fig = pygmt.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, + ) + + # Shape outline (over ends of compass lines for hexagon shape) + fig.plot(x=0, y=0, pen=f"{thick_shape}c,{blue}", **args_shape) + # fig.show() + + fig.plot(data=_bg_arrow_coords(), fill=color_bg, perspective=True) + + # Letter G + fig.plot(data=_letter_g_coords(), fill=red, perspective=True) + # Letter M + fig.plot(data=_letter_m_coords(), fill=red, perspective=True) + # Letter T: red curved horizontal line + fig.plot(data=_letter_t_coords(), fill=red, perspective=True) + + # Upper vertical lines + fig.plot(data=_vline_coords(gap=thick_comp), fill=color_bg, perspective=True) + 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, + ) + # fig.show() + + # Add wordmark "PyGMT" + if wordmark: + text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" + fig.text(text=text_wm, no_clip=True, **args_text_wm) + # fig.show() + + # Helpful for implementing the logo; not included in the logo + if debug: + # Gridlines + with pygmt.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.show() + fig_name_logo = "pygmt_logo" + fig.savefig(fname=f"{fig_name_logo}.eps") + + return fig_name_logo + + +def pygmtlogo( # noqa: PLR0913 + self, + color=True, + theme="light", + shape="circle", + wordmark=True, + position=None, # -> Use position parameter of Figure.image + width=None, # -> Use width parameter of Figure.image + height=None, # -> Use height parameter of Figure.image + box=None, # -> Use box parameter of Figure.image + projection=None, + region=None, + verbose=None, + panel=None, + transparency=None, +): + """ + Plot the PyGMT logo. + The design of the logo is kindly provided by `@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 [gray20] background). + wordmark + Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set + to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the + visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and + ``False`` to add no wordmark. + color + Set to ``True`` to use colors referring to Python (blue and yellow) and GMT + (red) [Default]. For ``False``, the logo is drawn in black and white. + + Examples + -------- + >>> import pygmt + >>> fig = pygmt.Figure() + >>> fig.basemap(region=[-90, -70, 0, 20], projection="M10c", frame=True) + >>> fig.pygmtlogo( + ... shape="circle", + ... theme="light", + ... wordmark="horizontal", + ... color=True, + ... position="BR", + ... height="1c", + ... ) + >>> fig.show() + """ + + # ----------------------------------------------------------------------------- + # Create logo file + # ----------------------------------------------------------------------------- + fig_name_logo = _create_logo( + color=color, theme=theme, shape=shape, wordmark=wordmark + ) + + # ----------------------------------------------------------------------------- + # Add to existing Figure instance + # ----------------------------------------------------------------------------- + self.image( + imagefile=f"{fig_name_logo}.eps", + position=position, + width=width, + height=height, + box=box, + projection=projection, + region=region, + verbose=verbose, + panel=panel, + transparency=transparency, + ) + + Path.unlink(f"{fig_name_logo}.eps") From e1c89647e1de0c537dabec3199bb7a79f940dda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 21 Apr 2026 14:26:49 +0200 Subject: [PATCH 324/379] Fixes for hexagon shape --- pygmt/src/pygmtlogo.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 26cc73d1e02..6c45f67baa8 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -71,12 +71,10 @@ def _create_logo( # noqa: PLR0915 symbol = "c" size_shape = r0 + r1 hex_factor = 1 - vline_y = r0 case "hexagon": symbol = "h" - size_shape = (r0 + 0.35) * 2 + size_shape = (r0 + 0.34) * 2 hex_factor = 1.1 - vline_y = r0 * 0.93 # Define wordmark font = "AvantGarde-Book" @@ -172,7 +170,7 @@ def _vline_coords(gap=0): Coordinates for vertical lines. """ x0 = (thick_gt + gap) / 2 - return {"x": [-x0, -x0, x0, x0], "y": [vline_y, r3, r3, vline_y]} + return {"x": [-x0, -x0, x0, x0], "y": [r0, r3, r3, r0]} fig = pygmt.Figure() fig.basemap(region=region, projection=proj, perspective=perspective, frame="none") @@ -192,6 +190,7 @@ def _vline_coords(gap=0): pen=f"{thick_comp}c,{yellow}", style="v0c+s", perspective=True, + no_clip=True, ) # Shape outline (over ends of compass lines for hexagon shape) From 98768a989ea828753f027ed21812208ad3e4100c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:35:32 +0200 Subject: [PATCH 325/379] Adjust function explanation for letter T Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 26cc73d1e02..4b1348f43ba 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -122,7 +122,7 @@ def _letter_m_coords(): return {"x": m_x, "y": m_y} def _letter_t_coords(): - """Coordinates of the top curved horizontal line for letter T.""" + """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 From a5ba62a8c1f23d74f0d3ee1508a64975dbd8b4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:36:31 +0200 Subject: [PATCH 326/379] Combine comment for letters Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4b1348f43ba..75b7ac880ba 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -200,11 +200,9 @@ def _vline_coords(gap=0): fig.plot(data=_bg_arrow_coords(), fill=color_bg, perspective=True) - # Letter G + # Letters G, M, and T fig.plot(data=_letter_g_coords(), fill=red, perspective=True) - # Letter M fig.plot(data=_letter_m_coords(), fill=red, perspective=True) - # Letter T: red curved horizontal line fig.plot(data=_letter_t_coords(), fill=red, perspective=True) # Upper vertical lines From 6b8525955d82df78bb8ba70e152dd8903c2bbebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:37:18 +0200 Subject: [PATCH 327/379] Plot background line and arrow together Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 75b7ac880ba..1d85c5c82bd 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -198,6 +198,8 @@ def _vline_coords(gap=0): fig.plot(x=0, y=0, pen=f"{thick_shape}c,{blue}", **args_shape) # fig.show() + # Background vertical line and arrow head + fig.plot(data=_vline_coords(gap=thick_comp), fill=color_bg, perspective=True) fig.plot(data=_bg_arrow_coords(), fill=color_bg, perspective=True) # Letters G, M, and T @@ -205,8 +207,7 @@ def _vline_coords(gap=0): fig.plot(data=_letter_m_coords(), fill=red, perspective=True) fig.plot(data=_letter_t_coords(), fill=red, perspective=True) - # Upper vertical lines - fig.plot(data=_vline_coords(gap=thick_comp), fill=color_bg, 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 From fa628d573b7c64fd6feb776fc2305a2a402867ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 15:49:27 +0200 Subject: [PATCH 328/379] Adjust gap for arrow --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 1d85c5c82bd..593cfd3611f 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -149,7 +149,7 @@ def _bg_arrow_coords(): # x0, y0 is the same as in _letter_t_coords(). x0 = thick_gt / 2 y0 = 2 * x0 * np.sqrt(3) - arrow_x = [-x0 * 3.0, -x0, x0, x0 * 3.0] + arrow_x = [-x0 * 2 - thick_comp/2, -thick_comp/2, thick_comp/2, x0 * 2 + thick_comp/2] arrow_y = [-r0 + y0, -r0, -r0, -r0 + y0] return {"x": arrow_x, "y": arrow_y} From 96c9ed2e46ae3b0751672207a86f49760d1d53d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 15:50:15 +0200 Subject: [PATCH 329/379] Adjust size of arrow head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 593cfd3611f..45ee3ddffa3 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -129,7 +129,7 @@ def _letter_t_coords(): 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 = 2 * x0 * np.sqrt(3) # Height 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 @@ -148,7 +148,7 @@ def _bg_arrow_coords(): """Coordinates for the background arrow.""" # x0, y0 is the same as in _letter_t_coords(). x0 = thick_gt / 2 - y0 = 2 * x0 * np.sqrt(3) + y0 = 1.8 * x0 * np.sqrt(3) arrow_x = [-x0 * 2 - thick_comp/2, -thick_comp/2, thick_comp/2, x0 * 2 + thick_comp/2] arrow_y = [-r0 + y0, -r0, -r0, -r0 + y0] return {"x": arrow_x, "y": arrow_y} From 2964869b73f6e069169d303ae5d5a5604cd51e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 21 Apr 2026 16:27:16 +0200 Subject: [PATCH 330/379] Fix line length --- pygmt/src/pygmtlogo.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index bb13781343d..d1607ee126e 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -147,7 +147,12 @@ def _bg_arrow_coords(): # x0, y0 is the same as in _letter_t_coords(). x0 = thick_gt / 2 y0 = 1.8 * x0 * np.sqrt(3) - arrow_x = [-x0 * 2 - thick_comp/2, -thick_comp/2, thick_comp/2, x0 * 2 + thick_comp/2] + arrow_x = [ + -x0 * 2 - thick_comp / 2, + -thick_comp / 2, + thick_comp / 2, + x0 * 2 + thick_comp / 2, + ] arrow_y = [-r0 + y0, -r0, -r0, -r0 + y0] return {"x": arrow_x, "y": arrow_y} From 7efd08d10f2b53d22462820f7b05ab6a82ceb01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 21 Apr 2026 19:11:53 +0200 Subject: [PATCH 331/379] Remove gallery example --- examples/gallery/embellishments/pygmt_logo.py | 83 ------------------- 1 file changed, 83 deletions(-) delete mode 100644 examples/gallery/embellishments/pygmt_logo.py diff --git a/examples/gallery/embellishments/pygmt_logo.py b/examples/gallery/embellishments/pygmt_logo.py deleted file mode 100644 index db8c5bdf0ee..00000000000 --- a/examples/gallery/embellishments/pygmt_logo.py +++ /dev/null @@ -1,83 +0,0 @@ -""" -PyGMT logo -========== -Beside the GMT logo, there is a separate PyGMT logo which can be plotted and added -to a figure using :meth:`pygmt.Figure.pygmtlogo`. The design of the logo itself is -kindly provided by `@sfrooti `_ and consists of a visual -and the wordmark "PyGMT". -The logo is available in circle and hexagon shapes. It can be plotted using colors of -Python (blue and yellow) and GMT (red) or in black and white as well as in light or -dark mode. The wordmark can be added on the right side or bottom of the visual. -""" - -# %% -import pygmt - -# All versions -# modified from -# https://github.com/GenericMappingTools/pygmt/pull/3849#issuecomment-2753372170 -# by @seisman -fig = pygmt.Figure() - -# Logo without workmark. -fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame=["a1f1g1", "+ggray50"]) -for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: - for color, shape in [ - (True, "circle"), - (True, "hexagon"), - (False, "circle"), - (False, "hexagon"), - ]: - fig.pygmtlogo( - color=color, - theme=theme, - shape=shape, - wordmark=False, - position=f"g{x}/{y}+jTL+w2c", - ) - y += 3 # noqa: PLW2901 - -fig.shift_origin(xshift=8) - -# Logo with vertical wordmark. -fig.basemap(region=[0, 7, 0, 13], projection="x1c", frame=["a1f1g1", "+ggray50"]) -for x, y, theme in [(1, 3, "light"), (4, 3, "dark")]: - for color, shape in [ - (True, "circle"), - (True, "hexagon"), - (False, "circle"), - (False, "hexagon"), - ]: - fig.pygmtlogo( - color=color, - theme=theme, - shape=shape, - wordmark="vertical", - position=f"g{x}/{y}+jTL+w2c", - ) - y += 3 # noqa: PLW2901 - -fig.shift_origin(xshift=8) - -# Logo with horizontal wordmark. -fig.basemap(region=[0, 20, 0, 13], projection="x1c", frame=["a1f1g1", "+ggray50"]) -for x, y, theme in [(1, 3, "light"), (11, 3, "dark")]: - for color, shape in [ - (True, "circle"), - (True, "hexagon"), - (False, "circle"), - (False, "hexagon"), - ]: - fig.pygmtlogo( - color=color, - theme=theme, - shape=shape, - wordmark="horizontal", - position=f"g{x}/{y}+jTL+w0/2c", - ) - y += 3 # noqa: PLW2901 - -fig.show(width=1000) - - -# sphinx_gallery_thumbnail_number = 1 From 160dcdf7d297143977a4857bf562586d15d65a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 21 Apr 2026 19:19:55 +0200 Subject: [PATCH 332/379] Update and add tests --- pygmt/tests/test_pygmtlogo.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index 8e6803298d9..b2a10dcd11e 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -18,13 +18,13 @@ def test_pylogo(): @pytest.mark.mpl_image_compare -def test_pylogo_on_a_map(): +def test_pylogo_vertical_wordmark(): """ - Plot the PyGMT logo and adjust the position, offset, and size. + Plot the PyGMT logo with vertical orientation of the wordmark. """ fig = Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) - fig.pygmtlogo(position="jMC+o0.25c/0.25c+w7.5c", box=True) + fig.pygmtlogo(wordmark="vertical") return fig @@ -40,7 +40,7 @@ def test_pylogo_no_wordmark(): @pytest.mark.mpl_image_compare -def test_pylogo_lightmode(): +def test_pylogo_color_darkmode(): """ Plot the PyGMT logo in dark mode. """ @@ -51,11 +51,22 @@ def test_pylogo_lightmode(): @pytest.mark.mpl_image_compare -def test_pylogo_vertical(): +def test_pylogo_blackwhite_light(): """ - Plot the PyGMT logo with vertical orientation of the wordmark. + Plot the PyGMT logo in dark mode. """ fig = Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) - fig.pygmtlogo(wordmark="vertical") + fig.pygmtlogo(color=False) + return fig + + +@pytest.mark.mpl_image_compare +def test_pylogo_backwhite_dark(): + """ + Plot the PyGMT logo in dark mode. + """ + fig = Figure() + fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) + fig.pygmtlogo(color=False, theme="dark") return fig From 8bc5a820a0eef2f71b130535a27ea0838185f17f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:46:45 +0200 Subject: [PATCH 333/379] Plot vertical line and arrow head as one polygon Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d1607ee126e..4ff021e1f66 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -147,13 +147,12 @@ def _bg_arrow_coords(): # x0, y0 is the same as in _letter_t_coords(). x0 = thick_gt / 2 y0 = 1.8 * x0 * np.sqrt(3) - arrow_x = [ - -x0 * 2 - thick_comp / 2, - -thick_comp / 2, - thick_comp / 2, - x0 * 2 + thick_comp / 2, - ] - arrow_y = [-r0 + y0, -r0, -r0, -r0 + y0] + # The background arrow is thick_comp wide 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(): @@ -170,11 +169,11 @@ def _compass_lines(): (x1, -x1, x2, -x2), # lower right ] - def _vline_coords(gap=0): + def _vline_coords(): """ - Coordinates for vertical lines. + Coordinates for the vertical line at the top. """ - x0 = (thick_gt + gap) / 2 + x0 = thick_gt / 2 return {"x": [-x0, -x0, x0, x0], "y": [r0, r3, r3, r0]} fig = pygmt.Figure() @@ -202,8 +201,7 @@ def _vline_coords(gap=0): fig.plot(x=0, y=0, pen=f"{thick_shape}c,{blue}", **args_shape) # fig.show() - # Background vertical line and arrow head - fig.plot(data=_vline_coords(gap=thick_comp), fill=color_bg, perspective=True) + # Arrow in background color (over shape outline but under letters) fig.plot(data=_bg_arrow_coords(), fill=color_bg, perspective=True) # Letters G, M, and T From 562ffa4dc30554e34c19dac0603d3ed8d2c69004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 22 Apr 2026 15:34:36 +0200 Subject: [PATCH 334/379] Fix typo --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4ff021e1f66..9e0ec480898 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -147,7 +147,7 @@ def _bg_arrow_coords(): # 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 wide than the letter T. + # 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 From bf3d63723dd236796c03ac00bd071efcc94063d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 22 Apr 2026 16:21:12 +0200 Subject: [PATCH 335/379] Reduce tests --- pygmt/tests/test_pygmtlogo.py | 54 ++++------------------------------- 1 file changed, 5 insertions(+), 49 deletions(-) diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index b2a10dcd11e..2dc550a713f 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -8,65 +8,21 @@ @pytest.mark.benchmark @pytest.mark.mpl_image_compare -def test_pylogo(): +def test_pylogo_color_light_nowordmark(): """ - Plot the PyGMT logo using the default settings. + Plot the PyGMT logo without the wordmark in color using light mode. """ fig = Figure() - fig.pygmtlogo() - return fig - - -@pytest.mark.mpl_image_compare -def test_pylogo_vertical_wordmark(): - """ - Plot the PyGMT logo with vertical orientation of the wordmark. - """ - fig = Figure() - fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) - fig.pygmtlogo(wordmark="vertical") - return fig - - -@pytest.mark.mpl_image_compare -def test_pylogo_no_wordmark(): - """ - Plot the PyGMT logo without wordmark. - """ - fig = Figure() - fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) fig.pygmtlogo(wordmark=False) return fig @pytest.mark.mpl_image_compare -def test_pylogo_color_darkmode(): - """ - Plot the PyGMT logo in dark mode. - """ - fig = Figure() - fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) - fig.pygmtlogo(theme="dark") - return fig - - -@pytest.mark.mpl_image_compare -def test_pylogo_blackwhite_light(): - """ - Plot the PyGMT logo in dark mode. - """ - fig = Figure() - fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) - fig.pygmtlogo(color=False) - return fig - - -@pytest.mark.mpl_image_compare -def test_pylogo_backwhite_dark(): +def test_pylogo_color_dark_nowordmark(): """ - Plot the PyGMT logo in dark mode. + Plot the PyGMT logo without the wordmark in color using dark mode. """ fig = Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) - fig.pygmtlogo(color=False, theme="dark") + fig.pygmtlogo(wordmark=False, mode="dark") return fig From fb23907574b19b31ba2874a3114c5006acbb4496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 22 Apr 2026 18:22:24 +0200 Subject: [PATCH 336/379] Update intro text Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 9e0ec480898..8279cccd00c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -1,6 +1,7 @@ """ -pygmtlogo - Create and plot the PyGMT logo. -The design of the logo is kindly provided by `@sfrooti `_ +pygmtlogo - Plot the PyGMT logo. + +The initial design of the logo is kindly provided by `@sfrooti `_ and consists of a visual and the wordmark "PyGMT". """ From 698ddd764ac8f8ea48eb43df8abdfd77e72569a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 22 Apr 2026 18:27:17 +0200 Subject: [PATCH 337/379] Remove fig.show() Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 8279cccd00c..33bb2a42e3a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -200,7 +200,6 @@ def _vline_coords(): # Shape outline (over ends of compass lines for hexagon shape) fig.plot(x=0, y=0, pen=f"{thick_shape}c,{blue}", **args_shape) - # fig.show() # Arrow in background color (over shape outline but under letters) fig.plot(data=_bg_arrow_coords(), fill=color_bg, perspective=True) @@ -223,13 +222,11 @@ def _vline_coords(): perspective=True, no_clip=True, ) - # fig.show() # Add wordmark "PyGMT" if wordmark: text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" fig.text(text=text_wm, no_clip=True, **args_text_wm) - # fig.show() # Helpful for implementing the logo; not included in the logo if debug: @@ -245,7 +242,6 @@ def _vline_coords(): 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.show() fig_name_logo = "pygmt_logo" fig.savefig(fname=f"{fig_name_logo}.eps") From 04f2ca5d378ceb6309aa43df959c26d83c81d55d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 22 Apr 2026 18:28:40 +0200 Subject: [PATCH 338/379] Remove the projection and region parameters Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 33bb2a42e3a..e620035e7d8 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -258,8 +258,6 @@ def pygmtlogo( # noqa: PLR0913 width=None, # -> Use width parameter of Figure.image height=None, # -> Use height parameter of Figure.image box=None, # -> Use box parameter of Figure.image - projection=None, - region=None, verbose=None, panel=None, transparency=None, From 59e56cb68d869ea6c10556060d07fc9d372e13ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 22 Apr 2026 18:29:33 +0200 Subject: [PATCH 339/379] Adjust formating of comments Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e620035e7d8..733b6cef7df 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -300,17 +300,12 @@ def pygmtlogo( # noqa: PLR0913 ... ) >>> fig.show() """ - - # ----------------------------------------------------------------------------- # Create logo file - # ----------------------------------------------------------------------------- fig_name_logo = _create_logo( color=color, theme=theme, shape=shape, wordmark=wordmark ) - # ----------------------------------------------------------------------------- # Add to existing Figure instance - # ----------------------------------------------------------------------------- self.image( imagefile=f"{fig_name_logo}.eps", position=position, From 25b55adf3de014be2df30e8d57e5590738f6c14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 22 Apr 2026 18:31:21 +0200 Subject: [PATCH 340/379] Simplify calculation of thickness Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 733b6cef7df..f183c3260b0 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -37,7 +37,7 @@ def _create_logo( # noqa: PLR0915 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_comp / 4) * 3 + thick_gap = thick_shape / 4 # Rotation around z (vertical) axis placed in the center # Has to be applied to each plotting command, up on second call set to True From 13ad3b65afca8a25bcb9ea66b296cbc3d76458a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 22 Apr 2026 18:42:33 +0200 Subject: [PATCH 341/379] Remove region and projection parameters --- pygmt/src/pygmtlogo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index f183c3260b0..64d6677c3b4 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -312,8 +312,6 @@ def pygmtlogo( # noqa: PLR0913 width=width, height=height, box=box, - projection=projection, - region=region, verbose=verbose, panel=panel, transparency=transparency, From 729aa006c2ce54bf8ec5d7e4b1712af59a70e652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 23 Apr 2026 12:49:50 +0200 Subject: [PATCH 342/379] No wordmark by default --- pygmt/src/pygmtlogo.py | 12 ++++++------ pygmt/tests/test_pygmtlogo.py | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 64d6677c3b4..6be788af35b 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -17,7 +17,7 @@ def _create_logo( # noqa: PLR0915 shape: Literal["circle", "hexagon"] = "circle", theme: Literal["light", "dark"] = "light", - wordmark: Literal["horizontal", "vertical"] | bool = True, + wordmark: Literal["horizontal", "vertical"] | bool = False, color: bool = True, debug: bool = False, ): @@ -253,7 +253,7 @@ def pygmtlogo( # noqa: PLR0913 color=True, theme="light", shape="circle", - wordmark=True, + wordmark=False, position=None, # -> Use position parameter of Figure.image width=None, # -> Use width parameter of Figure.image height=None, # -> Use height parameter of Figure.image @@ -277,10 +277,10 @@ def pygmtlogo( # noqa: PLR0913 Use ``"light"`` for light mode (i.e., a white background) [Default] and ``"dark"`` for dark mode (i.e., a darkgray [gray20] background). wordmark - Add the wordmark "PyGMT" and adjust its orientation relative to the visual. Set - to ``True`` or ``"horizontal"``, to add the wordmark at the right side of the - visual [Default]. Use ``"vertical"`` to place the wordmark below the visual and - ``False`` to add no wordmark. + Add the wordmark "PyGMT" and adjust its orientation relative to the visual. + ``True`` or ``"horizontal"`` adds the wordmark at the right side of the visual. + Use ``"vertical"`` to place the wordmark below the visual and ``False`` to add + no wordmark [Default]. color Set to ``True`` to use colors referring to Python (blue and yellow) and GMT (red) [Default]. For ``False``, the logo is drawn in black and white. diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index 2dc550a713f..4115a521c29 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -10,19 +10,19 @@ @pytest.mark.mpl_image_compare def test_pylogo_color_light_nowordmark(): """ - Plot the PyGMT logo without the wordmark in color using light mode. + Plot the PyGMT logo without wordmark in color using light mode. """ fig = Figure() - fig.pygmtlogo(wordmark=False) + fig.pygmtlogo() return fig @pytest.mark.mpl_image_compare def test_pylogo_color_dark_nowordmark(): """ - Plot the PyGMT logo without the wordmark in color using dark mode. + Plot the PyGMT logo without wordmark in color using dark mode. """ fig = Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) - fig.pygmtlogo(wordmark=False, mode="dark") + fig.pygmtlogo(mode="dark") return fig From fac0aba8426a002e2ab37586f1e7838cfe20ef34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 25 Apr 2026 00:01:34 +0200 Subject: [PATCH 343/379] Import pygmt into private function Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6be788af35b..a0d48072e94 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -9,7 +9,6 @@ from typing import Literal import numpy as np -import pygmt __doctest_skip__ = ["pygmtlogo"] @@ -24,6 +23,7 @@ def _create_logo( # noqa: PLR0915 """ Create the PyGMT logo using PyGMT. """ + from pygmt.figure import Figure # noqa: PLC0415 # Helpful definitions size = 4 @@ -177,7 +177,7 @@ def _vline_coords(): x0 = thick_gt / 2 return {"x": [-x0, -x0, x0, x0], "y": [r0, r3, r3, r0]} - fig = pygmt.Figure() + fig = Figure() fig.basemap(region=region, projection=proj, perspective=perspective, frame="none") # Earth - circle / hexagon @@ -230,8 +230,9 @@ def _vline_coords(): # Helpful for implementing the logo; not included in the logo if debug: + from pygmt import config # noqa: PLC0415 # Gridlines - with pygmt.config(MAP_FRAME_TYPE="inside", MAP_GRID_PEN="0.1p,gray30"): + 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]: From ece82140cfb7b9c41cc2f00df5f1b0966ab63be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 25 Apr 2026 00:03:55 +0200 Subject: [PATCH 344/379] Move definition of perspective Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index a0d48072e94..d13f1dfb31d 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -29,6 +29,9 @@ def _create_logo( # noqa: PLR0915 size = 4 region = [-size, size] * 2 proj = "x1c" + # Rotation around z (vertical) axis placed in the center + # Has to be applied to each plotting command, up on second call set to True + perspective = "30+w0/0" # by 30 degrees counter-clockwise # Radii (make sure that r4-r5 == r2-r3) r0, r1, r2, r3, r4, r5 = size * np.array([256, 224, 150, 122, 106, 78]) / 256 @@ -39,9 +42,6 @@ def _create_logo( # noqa: PLR0915 thick_comp = thick_shape / 3 # for compass lines thick_gap = thick_shape / 4 - # Rotation around z (vertical) axis placed in the center - # Has to be applied to each plotting command, up on second call set to True - perspective = "30+w0/0" # by 30 degrees counter-clockwise # Define colors color_light = "white" From 87784432a131bb688aacaa41513144eb0efea372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 25 Apr 2026 00:06:30 +0200 Subject: [PATCH 345/379] Use wordmark="none" instead of wordmark=False Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d13f1dfb31d..d37ba95e4d5 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -16,7 +16,7 @@ def _create_logo( # noqa: PLR0915 shape: Literal["circle", "hexagon"] = "circle", theme: Literal["light", "dark"] = "light", - wordmark: Literal["horizontal", "vertical"] | bool = False, + wordmark: Literal["none", "horizontal", "vertical"] = "none", color: bool = True, debug: bool = False, ): @@ -82,7 +82,7 @@ def _create_logo( # noqa: PLR0915 match wordmark: case "vertical": args_text_wm = {"x": 0, "y": -4.5, "justify": "CT", "font": f"2.5c,{font}"} - case True | "horizontal": + case "horizontal": args_text_wm = {"x": 4.5, "y": 0.8, "justify": "LM", "font": f"8c,{font}"} def _letter_g_coords(): @@ -224,7 +224,7 @@ def _vline_coords(): ) # Add wordmark "PyGMT" - if wordmark: + if wordmark != "none": text_wm = f"@;{color_py};Py@;;@;{color_gmt};GMT@;;" fig.text(text=text_wm, no_clip=True, **args_text_wm) From 1c1406c5ce016f521037c4c2987e684a9dbd95de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 25 Apr 2026 00:10:42 +0200 Subject: [PATCH 346/379] Use GMTTempoaryFile and pass a tempoary file Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index d37ba95e4d5..21ec368e3e7 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -18,6 +18,7 @@ def _create_logo( # noqa: PLR0915 theme: Literal["light", "dark"] = "light", wordmark: Literal["none", "horizontal", "vertical"] = "none", color: bool = True, + figname: str | Path = "pygmt_logo.eps", debug: bool = False, ): """ @@ -243,10 +244,7 @@ def _vline_coords(): 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_name_logo = "pygmt_logo" - fig.savefig(fname=f"{fig_name_logo}.eps") - - return fig_name_logo + fig.savefig(fname=figname) def pygmtlogo( # noqa: PLR0913 @@ -301,21 +299,26 @@ def pygmtlogo( # noqa: PLR0913 ... ) >>> fig.show() """ - # Create logo file - fig_name_logo = _create_logo( - color=color, theme=theme, shape=shape, wordmark=wordmark - ) + 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=f"{fig_name_logo}.eps", - position=position, - width=width, - height=height, - box=box, - verbose=verbose, - panel=panel, - transparency=transparency, - ) + # Add to existing Figure instance + self.image( + imagefile=logofile.name, + position=position, + width=width, + height=height, + box=box, + verbose=verbose, + panel=panel, + transparency=transparency, + ) Path.unlink(f"{fig_name_logo}.eps") From 7486e66256f7a4533a83407fad429a6dbab77bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 25 Apr 2026 00:12:25 +0200 Subject: [PATCH 347/379] Improve description of test Co-authored-by: Dongdong Tian --- pygmt/tests/test_pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index 4115a521c29..f61de3b9f3e 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -8,9 +8,9 @@ @pytest.mark.benchmark @pytest.mark.mpl_image_compare -def test_pylogo_color_light_nowordmark(): +def test_pygmtlogo(): """ - Plot the PyGMT logo without wordmark in color using light mode. + Plot the default PyGMT logo, colored, light theme, without wordmark. """ fig = Figure() fig.pygmtlogo() From 74ab0060ef6eb5bea9c4bc5a3ae464301af5e38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 25 Apr 2026 00:15:44 +0200 Subject: [PATCH 348/379] Fix style --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 21ec368e3e7..3e991c894a0 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -43,7 +43,6 @@ def _create_logo( # noqa: PLR0915 thick_comp = thick_shape / 3 # for compass lines thick_gap = thick_shape / 4 - # Define colors color_light = "white" color_dark = "gray20" @@ -232,6 +231,7 @@ def _vline_coords(): # Helpful for implementing the logo; not included in the logo if debug: from pygmt import config # noqa: PLC0415 + # Gridlines with config(MAP_FRAME_TYPE="inside", MAP_GRID_PEN="0.1p,gray30"): fig.basemap(frame="g1") From a4e378fc3af32873da99b64c2739704882e2546e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 25 Apr 2026 09:54:27 +0200 Subject: [PATCH 349/379] Add import of GMTTempFile --- pygmt/src/pygmtlogo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 3e991c894a0..de9f54bda53 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -261,6 +261,8 @@ def pygmtlogo( # noqa: PLR0913 panel=None, transparency=None, ): + from pygmt.helpers import GMTTempFile # noqa: PLC0415 + """ Plot the PyGMT logo. The design of the logo is kindly provided by `@sfrooti `_ From ee1951dc5c7fedf843e2b63ca2adac8c20292d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 25 Apr 2026 09:57:44 +0200 Subject: [PATCH 350/379] Move import below docstring --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index de9f54bda53..58daf8cef5c 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -261,8 +261,6 @@ def pygmtlogo( # noqa: PLR0913 panel=None, transparency=None, ): - from pygmt.helpers import GMTTempFile # noqa: PLC0415 - """ Plot the PyGMT logo. The design of the logo is kindly provided by `@sfrooti `_ @@ -301,6 +299,8 @@ def pygmtlogo( # noqa: PLR0913 ... ) >>> fig.show() """ + from pygmt.helpers import GMTTempFile # noqa: PLC0415 + with GMTTempFile(suffix=".eps") as logofile: # Create logo file _create_logo( From 8ae5c89ea88cfd3561ea6ae98cdbbe6e42895e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 25 Apr 2026 10:03:08 +0200 Subject: [PATCH 351/379] Fix file name variable --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 58daf8cef5c..8ba3fb7ad38 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -323,4 +323,4 @@ def pygmtlogo( # noqa: PLR0913 transparency=transparency, ) - Path.unlink(f"{fig_name_logo}.eps") + Path.unlink(f"{logofile.name}.eps") From 3cb5212ad01781bfe360b45d58f82e43cc1e7e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sat, 25 Apr 2026 13:39:45 +0200 Subject: [PATCH 352/379] Combine tests --- pygmt/tests/test_pygmtlogo.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index f61de3b9f3e..a7d90013f8f 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -10,19 +10,10 @@ @pytest.mark.mpl_image_compare def test_pygmtlogo(): """ - Plot the default PyGMT logo, colored, light theme, without wordmark. + Plot the default PyGMT logo, colored, light and dark themes, without wordmark. """ fig = Figure() fig.pygmtlogo() - return fig - - -@pytest.mark.mpl_image_compare -def test_pylogo_color_dark_nowordmark(): - """ - Plot the PyGMT logo without wordmark in color using dark mode. - """ - fig = Figure() - fig.basemap(region=[-5, 5, -5, 5], projection="X10c", frame=1) + fig.shift_origin(xshift="+w") fig.pygmtlogo(mode="dark") return fig From 0291e930bd3732b9bee1adecf4906b9341da2be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 26 Apr 2026 21:26:30 +0200 Subject: [PATCH 353/379] Add type hints Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 8ba3fb7ad38..2400975b569 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -5,10 +5,12 @@ and consists of a visual and the wordmark "PyGMT". """ -from pathlib import Path +from collections.abc import Sequence from typing import Literal import numpy as np +from pygmt._typing import AnchorCode, PathLike +from pygmt.params import Box, Position __doctest_skip__ = ["pygmtlogo"] @@ -18,7 +20,7 @@ def _create_logo( # noqa: PLR0915 theme: Literal["light", "dark"] = "light", wordmark: Literal["none", "horizontal", "vertical"] = "none", color: bool = True, - figname: str | Path = "pygmt_logo.eps", + figname: PathLike = "pygmt_logo.eps", debug: bool = False, ): """ @@ -249,17 +251,19 @@ def _vline_coords(): def pygmtlogo( # noqa: PLR0913 self, - color=True, - theme="light", - shape="circle", - wordmark=False, - position=None, # -> Use position parameter of Figure.image - width=None, # -> Use width parameter of Figure.image - height=None, # -> Use height parameter of Figure.image - box=None, # -> Use box parameter of Figure.image - verbose=None, - panel=None, - transparency=None, + 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, ): """ Plot the PyGMT logo. From afa08874c2c66cf216f764db6ece162f1b6a229f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 26 Apr 2026 21:27:27 +0200 Subject: [PATCH 354/379] Shorten docstring for theme Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 2400975b569..ee2261c55c4 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -278,7 +278,7 @@ def pygmtlogo( # noqa: PLR0913 ``"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 [gray20] background). + ``"dark"`` for dark mode (i.e., a darkgray background). wordmark Add the wordmark "PyGMT" and adjust its orientation relative to the visual. ``True`` or ``"horizontal"`` adds the wordmark at the right side of the visual. From de187e2c262194b70374fa450ad0b70f8a3761e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 26 Apr 2026 21:27:57 +0200 Subject: [PATCH 355/379] Use list for docstring of wordmark Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index ee2261c55c4..95b818a587a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -281,9 +281,11 @@ def pygmtlogo( # noqa: PLR0913 ``"dark"`` for dark mode (i.e., a darkgray background). wordmark Add the wordmark "PyGMT" and adjust its orientation relative to the visual. - ``True`` or ``"horizontal"`` adds the wordmark at the right side of the visual. - Use ``"vertical"`` to place the wordmark below the visual and ``False`` to add - no wordmark [Default]. + Valid values are: + + - ``"none"``: no wordmark [Default]. + - ``"horizontal"``: wordmark at the right side of the visual. + - ``"vertical"``: wordmark below the visual. color Set to ``True`` to use colors referring to Python (blue and yellow) and GMT (red) [Default]. For ``False``, the logo is drawn in black and white. From ee853740a3ae02bef0813f1c88f8ca749c01cfeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 26 Apr 2026 21:28:50 +0200 Subject: [PATCH 356/379] Shorten docstring for color Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 95b818a587a..e30a779a060 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -287,8 +287,7 @@ def pygmtlogo( # noqa: PLR0913 - ``"horizontal"``: wordmark at the right side of the visual. - ``"vertical"``: wordmark below the visual. color - Set to ``True`` to use colors referring to Python (blue and yellow) and GMT - (red) [Default]. For ``False``, the logo is drawn in black and white. + ``True`` for a color logo, and ``False`` for a black and white logo. Examples -------- From 382e2881a1675de59a4a9e1dd1d35d03b179a981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 26 Apr 2026 21:29:32 +0200 Subject: [PATCH 357/379] Remove deleting file Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e30a779a060..2f465779480 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -327,5 +327,3 @@ def pygmtlogo( # noqa: PLR0913 panel=panel, transparency=transparency, ) - - Path.unlink(f"{logofile.name}.eps") From 5b287396bd12c257dbffef3589887cd4645a5f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 26 Apr 2026 21:30:19 +0200 Subject: [PATCH 358/379] Add perspective parameter Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 2f465779480..3b51fb3afda 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -325,5 +325,6 @@ def pygmtlogo( # noqa: PLR0913 box=box, verbose=verbose, panel=panel, + perspective=perspective, transparency=transparency, ) From 9fc6c78d42ed8773e2651c6c74705ffd2d07f6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 27 Apr 2026 10:22:18 +0200 Subject: [PATCH 359/379] Import GMTTempFile at the beginning Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 3b51fb3afda..3a96e25e7d2 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -10,6 +10,7 @@ import numpy as np from pygmt._typing import AnchorCode, PathLike +from pygmt.helpers import GMTTempFile from pygmt.params import Box, Position __doctest_skip__ = ["pygmtlogo"] @@ -304,8 +305,6 @@ def pygmtlogo( # noqa: PLR0913 ... ) >>> fig.show() """ - from pygmt.helpers import GMTTempFile # noqa: PLC0415 - with GMTTempFile(suffix=".eps") as logofile: # Create logo file _create_logo( From f2d292259d83a4b85ac144a9b08e188fc6870de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 27 Apr 2026 10:22:48 +0200 Subject: [PATCH 360/379] Sorten comment for perspective parameter Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 3a96e25e7d2..018d0bedea2 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -33,9 +33,8 @@ def _create_logo( # noqa: PLR0915 size = 4 region = [-size, size] * 2 proj = "x1c" - # Rotation around z (vertical) axis placed in the center - # Has to be applied to each plotting command, up on second call set to True - perspective = "30+w0/0" # by 30 degrees counter-clockwise + # 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([256, 224, 150, 122, 106, 78]) / 256 From 6aafe47d611e11238635248dd70f893db46a7246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 28 Apr 2026 19:28:04 +0200 Subject: [PATCH 361/379] Update inline example --- pygmt/src/pygmtlogo.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 018d0bedea2..df9e3eff6de 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -292,13 +292,20 @@ def pygmtlogo( # noqa: PLR0913 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" 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( - ... shape="circle", - ... theme="light", ... wordmark="horizontal", - ... color=True, ... position="BR", ... height="1c", ... ) From 1c5118905fc2ad8c4658df67811607073c394714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 29 Apr 2026 14:57:19 +0200 Subject: [PATCH 362/379] Fix parameter name in test --- pygmt/tests/test_pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_pygmtlogo.py b/pygmt/tests/test_pygmtlogo.py index a7d90013f8f..fb117b9b097 100644 --- a/pygmt/tests/test_pygmtlogo.py +++ b/pygmt/tests/test_pygmtlogo.py @@ -15,5 +15,5 @@ def test_pygmtlogo(): fig = Figure() fig.pygmtlogo() fig.shift_origin(xshift="+w") - fig.pygmtlogo(mode="dark") + fig.pygmtlogo(theme="dark") return fig From 124d21aa1a84a582a0d5213a72216deaa6a2d8f0 Mon Sep 17 00:00:00 2001 From: Yvonne Date: Wed, 29 Apr 2026 13:21:33 +0000 Subject: [PATCH 363/379] Add test_pygmtlogo.png into DVC --- pygmt/tests/baseline/test_pygmtlogo.png.dvc | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 pygmt/tests/baseline/test_pygmtlogo.png.dvc diff --git a/pygmt/tests/baseline/test_pygmtlogo.png.dvc b/pygmt/tests/baseline/test_pygmtlogo.png.dvc new file mode 100755 index 00000000000..ea17241c5d1 --- /dev/null +++ b/pygmt/tests/baseline/test_pygmtlogo.png.dvc @@ -0,0 +1,6 @@ +outs: +- md5: 35c59c31c92f13c705a24933465ff551 + size: 14374 + isexec: true + hash: md5 + path: test_pygmtlogo.png From 6878e262e2514a8c9915b1024e416973209ba616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 29 Apr 2026 15:36:58 +0200 Subject: [PATCH 364/379] Remove execution permission --- pygmt/tests/baseline/test_pygmtlogo.png.dvc | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 pygmt/tests/baseline/test_pygmtlogo.png.dvc diff --git a/pygmt/tests/baseline/test_pygmtlogo.png.dvc b/pygmt/tests/baseline/test_pygmtlogo.png.dvc old mode 100755 new mode 100644 From 194c3e0830de3d6a0e6764adbf9d06506d2dc677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 29 Apr 2026 16:50:34 +0200 Subject: [PATCH 365/379] Adjust workflow dvc-diff --- .github/workflows/dvc-diff.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dvc-diff.yml b/.github/workflows/dvc-diff.yml index 0f744a0832a..0ead0c5abbc 100644 --- a/.github/workflows/dvc-diff.yml +++ b/.github/workflows/dvc-diff.yml @@ -37,6 +37,8 @@ jobs: - name: Setup continuous machine learning (CML) uses: iterative/setup-cml@1b5ab8766e715e8f1aab96bbb1f4f2e3e1e8af45 # v3 + with: + vega: false # Produce the markdown diff report, which should look like: # ## Summary of changed images From c614cdbe1f472680dfdbe3c0d880e3fc96dc9498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 29 Apr 2026 17:44:55 +0200 Subject: [PATCH 366/379] Use int for hex_factor Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index df9e3eff6de..7d506936405 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -73,7 +73,7 @@ def _create_logo( # noqa: PLR0915 case "circle": symbol = "c" size_shape = r0 + r1 - hex_factor = 1 + hex_factor = 1.0 case "hexagon": symbol = "h" size_shape = (r0 + 0.34) * 2 From 3597bd585ac149dcf5b635ceb2c88cb0d3198de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 29 Apr 2026 23:34:55 +0200 Subject: [PATCH 367/379] Give radii in a fraction of 128 Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 7d506936405..69c374aa42a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -37,7 +37,7 @@ def _create_logo( # noqa: PLR0915 perspective = "30+w0/0" # Radii (make sure that r4-r5 == r2-r3) - r0, r1, r2, r3, r4, r5 = size * np.array([256, 224, 150, 122, 106, 78]) / 256 + 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 From 4bc9f684faa750b84973c60b419a84352c2cc28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 30 Apr 2026 15:31:45 +0200 Subject: [PATCH 368/379] Extend docstrings --- pygmt/src/pygmtlogo.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 69c374aa42a..3cb574bb5c7 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -288,6 +288,17 @@ def pygmtlogo( # noqa: PLR0913 - ``"vertical"``: wordmark below the visual. color ``True`` for a color logo, and ``False`` for a black and white logo. + width + Set the width of the logo. + hight + Set the hight of the logo. + $position + box + Add a box around the logo. + $verbose + $panel + $perspective + $transparency Examples -------- From 4a9c09bc28f04e55352927a31e3e077c223d9622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 30 Apr 2026 23:31:15 +0200 Subject: [PATCH 369/379] Fix docstrings taken from helpers --- pygmt/src/pygmtlogo.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 3cb574bb5c7..fefaa5e6d23 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -10,7 +10,10 @@ import numpy as np from pygmt._typing import AnchorCode, PathLike -from pygmt.helpers import GMTTempFile +from pygmt.helpers import ( + GMTTempFile, + fmt_docstring, +) from pygmt.params import Box, Position __doctest_skip__ = ["pygmtlogo"] @@ -249,6 +252,7 @@ def _vline_coords(): fig.savefig(fname=figname) +@fmt_docstring def pygmtlogo( # noqa: PLR0913 self, shape: Literal["circle", "hexagon"] = "circle", @@ -265,7 +269,7 @@ def pygmtlogo( # noqa: PLR0913 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 `_ and consists of a visual and the wordmark "PyGMT". From 1cb524c7a08f3121df8e1985240f27de3a038b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 30 Apr 2026 23:35:16 +0200 Subject: [PATCH 370/379] Improve comment for inline example --- pygmt/src/pygmtlogo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index fefaa5e6d23..e80b2192651 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -314,8 +314,8 @@ def pygmtlogo( # noqa: PLR0913 >>> fig.pygmtlogo() >>> fig.show() - Plot the PyGMT logo with the wordmark "PyGMT" at the right side in the Bottom Right - corner on an existing basemap: + 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) From 58123a721c2920909aedc3247a5e24844e343904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 30 Apr 2026 23:52:37 +0200 Subject: [PATCH 371/379] Add docstring for position parameter --- pygmt/src/pygmtlogo.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index e80b2192651..4ec50a32ce1 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -296,7 +296,18 @@ def pygmtlogo( # noqa: PLR0913 Set the width of the logo. hight Set the hight of the logo. - $position + 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 ` 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"``). box Add a box around the logo. $verbose From 47699a881ff1a7027e55d26dca0e9d96565be806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 1 May 2026 00:06:55 +0200 Subject: [PATCH 372/379] Add docstrings for width, height, and box --- pygmt/src/pygmtlogo.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4ec50a32ce1..384ec7a6f21 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -276,7 +276,6 @@ def pygmtlogo( # noqa: PLR0913 Parameters ---------- - shape Shape of the visual logo. Use ``"circle"`` for a circle shape [Default] or ``"hexagon"`` for a hexagon shape. @@ -292,10 +291,6 @@ def pygmtlogo( # noqa: PLR0913 - ``"vertical"``: wordmark below the visual. color ``True`` for a color logo, and ``False`` for a black and white logo. - width - Set the width of the logo. - hight - Set the hight of the logo. position Position of the GMT logo on the plot. It can be specified in multiple ways: @@ -308,8 +303,15 @@ def pygmtlogo( # noqa: PLR0913 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 - Add a box around the logo. + 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 From ec3b72d02a52de46df98726f861cdd9475d1ff45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 1 May 2026 08:00:55 +0200 Subject: [PATCH 373/379] Use full line length Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 384ec7a6f21..6166aadea19 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -10,10 +10,7 @@ import numpy as np from pygmt._typing import AnchorCode, PathLike -from pygmt.helpers import ( - GMTTempFile, - fmt_docstring, -) +from pygmt.helpers import GMTTempFile, fmt_docstring from pygmt.params import Box, Position __doctest_skip__ = ["pygmtlogo"] From 31972c2299e3ff41172988ef3d5036ed4a277daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 1 May 2026 08:40:59 +0200 Subject: [PATCH 374/379] Add pygmtlogo to figure.py --- pygmt/figure.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygmt/figure.py b/pygmt/figure.py index a1494c29fd8..ccf3a21d292 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -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 @@ -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 From 76d39b2deb92c977c6221c9d7e6f9bf8903e6241 Mon Sep 17 00:00:00 2001 From: Yvonne Date: Fri, 1 May 2026 08:11:11 +0000 Subject: [PATCH 375/379] Add test_pygmtlogo.png into DVC --- pygmt/tests/baseline/test_pygmtlogo.png.dvc | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/tests/baseline/test_pygmtlogo.png.dvc b/pygmt/tests/baseline/test_pygmtlogo.png.dvc index ea17241c5d1..010f8e4c4db 100644 --- a/pygmt/tests/baseline/test_pygmtlogo.png.dvc +++ b/pygmt/tests/baseline/test_pygmtlogo.png.dvc @@ -1,6 +1,5 @@ outs: - md5: 35c59c31c92f13c705a24933465ff551 size: 14374 - isexec: true hash: md5 path: test_pygmtlogo.png From c50789e2c079c971065b5f8735f739a0f80c0e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 1 May 2026 16:10:39 +0200 Subject: [PATCH 376/379] Try without "r" for docstrings Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 6166aadea19..4216515cf5a 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -266,7 +266,7 @@ def pygmtlogo( # noqa: PLR0913 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 `_ and consists of a visual and the wordmark "PyGMT". From 6077fc4c82db4e0ba24770109bc008495c5f08f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 1 May 2026 16:11:12 +0200 Subject: [PATCH 377/379] Use full line length Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index 4216515cf5a..b50485e01e2 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -329,11 +329,7 @@ def pygmtlogo( # noqa: PLR0913 >>> fig = pygmt.Figure() >>> fig.basemap(region=[-90, -70, 0, 20], projection="M10c", frame=True) - >>> fig.pygmtlogo( - ... wordmark="horizontal", - ... position="BR", - ... height="1c", - ... ) + >>> fig.pygmtlogo(wordmark="horizontal", position="BR", height="1c") >>> fig.show() """ with GMTTempFile(suffix=".eps") as logofile: From 8d3f3b0b63fdcdd183fb2d893f23b61519b2c464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 2 May 2026 08:26:32 +0200 Subject: [PATCH 378/379] Add blank line Co-authored-by: Dongdong Tian --- pygmt/src/pygmtlogo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index b50485e01e2..a067d7faa07 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -268,6 +268,7 @@ def pygmtlogo( # noqa: PLR0913 ): """ Plot the PyGMT logo. + The design of the logo is kindly provided by `@sfrooti `_ and consists of a visual and the wordmark "PyGMT". From 3265f78f8b0fc989a5adf5943a0c17eb50a700b7 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Sat, 2 May 2026 07:55:30 +0000 Subject: [PATCH 379/379] [format-command] fixes --- pygmt/src/pygmtlogo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/pygmtlogo.py b/pygmt/src/pygmtlogo.py index a067d7faa07..8da5e008f16 100644 --- a/pygmt/src/pygmtlogo.py +++ b/pygmt/src/pygmtlogo.py @@ -268,7 +268,7 @@ def pygmtlogo( # noqa: PLR0913 ): """ Plot the PyGMT logo. - + The design of the logo is kindly provided by `@sfrooti `_ and consists of a visual and the wordmark "PyGMT".