From 2a319b73ea8a6e1e767ec876100efa2e80920bcc Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 13:06:02 +0100 Subject: [PATCH 001/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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/174] 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,