From b04b732cbc3fc339e6c68c34d5d5e31e74ae12b7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 18 Mar 2025 22:10:32 +0100 Subject: [PATCH 1/9] Update to not use GMT logo as image --- examples/gallery/images/image.py | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/examples/gallery/images/image.py b/examples/gallery/images/image.py index 1806ae55577..f6730d9a83c 100644 --- a/examples/gallery/images/image.py +++ b/examples/gallery/images/image.py @@ -1,33 +1,23 @@ """ -Images on figures -================= +Image on figure +=============== -The :meth:`pygmt.Figure.image` method can be used to read and place an image -file in many formats (e.g., png, jpg, eps, pdf) on a figure. We must specify -the filename via the ``imagefile`` parameter or simply use the filename as -the first argument. You can also use a full URL pointing to your desired image. -The ``position`` parameter allows us to set a reference point on the map for -the image. +The :meth:`pygmt.Figure.image` method can be used to read and place an image file in +many formats (e.g., png, jpg, eps, pdf) on a figure. We must specify the filename via +the ``imagefile`` parameter or simply use the filename as the first argument. You can +also use a full URL pointing to your desired image. The ``position`` parameter allows +us to set a reference point on the map for the image. """ # %% -from pathlib import Path import pygmt fig = pygmt.Figure() fig.basemap(region=[0, 2, 0, 2], projection="X10c", frame=True) -# place and center the GMT logo from the GMT website to the position 1/1 -# on a basemap, scaled up to be 3 cm wide and draw a rectangular border -# around the image -fig.image( - imagefile="https://www.generic-mapping-tools.org/_static/gmt-logo.png", - position="g1/1+w3c+jCM", - box=True, -) - -# clean up the downloaded image in the current directory -Path("gmt-logo.png").unlink() +# Place and center ("+jCM") on image provided by GMT to the position ("+g") 1/1 on a +# basemap, scaled up to be 8 cm wide ("+w") and draw a rectangular border around it +fig.image(imagefile="@needle.jpg", position="g1/1+w8c+jCM", box=True) fig.show() From 7dcce0fb93a865a5008c0e1203d224c8e2cbd96b Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 19 Mar 2025 10:41:30 +0100 Subject: [PATCH 2/9] Fix typo --- examples/gallery/images/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/image.py b/examples/gallery/images/image.py index f6730d9a83c..2670c514e66 100644 --- a/examples/gallery/images/image.py +++ b/examples/gallery/images/image.py @@ -16,7 +16,7 @@ fig = pygmt.Figure() fig.basemap(region=[0, 2, 0, 2], projection="X10c", frame=True) -# Place and center ("+jCM") on image provided by GMT to the position ("+g") 1/1 on a +# Place and center ("+jCM") an image provided by GMT to the position ("+g") 1/1 on a # basemap, scaled up to be 8 cm wide ("+w") and draw a rectangular border around it fig.image(imagefile="@needle.jpg", position="g1/1+w8c+jCM", box=True) From f4533f03dbd8c7c0d4851b94bd97e186eb66bc25 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 19 Mar 2025 10:47:34 +0100 Subject: [PATCH 3/9] Fix typo --- examples/gallery/images/image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/image.py b/examples/gallery/images/image.py index 2670c514e66..f4be4a4c68b 100644 --- a/examples/gallery/images/image.py +++ b/examples/gallery/images/image.py @@ -1,6 +1,6 @@ """ -Image on figure -=============== +Image on a figure +================= The :meth:`pygmt.Figure.image` method can be used to read and place an image file in many formats (e.g., png, jpg, eps, pdf) on a figure. We must specify the filename via From 79459e740f41f06d1698d2ab6c33e2df3f67df27 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 19 Mar 2025 11:29:15 +0100 Subject: [PATCH 4/9] Improve forumulation --- examples/gallery/images/image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/image.py b/examples/gallery/images/image.py index f4be4a4c68b..08f0fdaf59e 100644 --- a/examples/gallery/images/image.py +++ b/examples/gallery/images/image.py @@ -16,8 +16,8 @@ fig = pygmt.Figure() fig.basemap(region=[0, 2, 0, 2], projection="X10c", frame=True) -# Place and center ("+jCM") an image provided by GMT to the position ("+g") 1/1 on a -# basemap, scaled up to be 8 cm wide ("+w") and draw a rectangular border around it +# Place and center ("+jCM") an image provided by GMT to the position ("+g") 1/1 on the +# current plot, scaled up to be 8 cm wide ("+w") and draw a rectangular border around it fig.image(imagefile="@needle.jpg", position="g1/1+w8c+jCM", box=True) fig.show() From e091dc68e59fefd9e1f78483311f8d53318229ad Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 19 Mar 2025 12:11:45 +0100 Subject: [PATCH 5/9] Use URL to image --- examples/gallery/images/image.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) mode change 100644 => 100755 examples/gallery/images/image.py diff --git a/examples/gallery/images/image.py b/examples/gallery/images/image.py old mode 100644 new mode 100755 index 08f0fdaf59e..3af4d6fe673 --- a/examples/gallery/images/image.py +++ b/examples/gallery/images/image.py @@ -10,14 +10,22 @@ """ # %% +from pathlib import Path import pygmt fig = pygmt.Figure() fig.basemap(region=[0, 2, 0, 2], projection="X10c", frame=True) -# Place and center ("+jCM") an image provided by GMT to the position ("+g") 1/1 on the -# current plot, scaled up to be 8 cm wide ("+w") and draw a rectangular border around it -fig.image(imagefile="@needle.jpg", position="g1/1+w8c+jCM", box=True) +# Place and center ("+jCM") an image to the position ("+g") 1/1 on the current plot, +# scale it to a width of 8 centimeters ("+w") and draw a rectangular border around it +fig.image( + imagefile="https://www.emirates247.com/polopoly_fs/1.569712.1452551297!/image/image.jpg", + position="g1/1+w8c+jCM", + box=True, +) fig.show() + +# Clean up the downloaded image in the current directory +Path("image.jpg").unlink() From 9f6988e5c68da0c4a05f5af69c0b776495cbf76b Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 19 Mar 2025 12:29:19 +0100 Subject: [PATCH 6/9] Remove execution permission --- examples/gallery/images/image.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/images/image.py diff --git a/examples/gallery/images/image.py b/examples/gallery/images/image.py old mode 100755 new mode 100644 From 01f6a32cb072821cf79cbccf7a8e758af8f526ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 19 Mar 2025 15:11:11 +0100 Subject: [PATCH 7/9] Use URL to GMT Co-authored-by: Dongdong Tian --- examples/gallery/images/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/image.py b/examples/gallery/images/image.py index 3af4d6fe673..c8c92833ffc 100644 --- a/examples/gallery/images/image.py +++ b/examples/gallery/images/image.py @@ -20,7 +20,7 @@ # Place and center ("+jCM") an image to the position ("+g") 1/1 on the current plot, # scale it to a width of 8 centimeters ("+w") and draw a rectangular border around it fig.image( - imagefile="https://www.emirates247.com/polopoly_fs/1.569712.1452551297!/image/image.jpg", + imagefile="https://oceania.generic-mapping-tools.org/cache/needle.jpg", position="g1/1+w8c+jCM", box=True, ) From d39ae3fe88acd7a918f39acd4ec1907bf6f5f086 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 19 Mar 2025 15:23:06 +0100 Subject: [PATCH 8/9] Update file name --- examples/gallery/images/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/image.py b/examples/gallery/images/image.py index c8c92833ffc..3f86116eb77 100644 --- a/examples/gallery/images/image.py +++ b/examples/gallery/images/image.py @@ -28,4 +28,4 @@ fig.show() # Clean up the downloaded image in the current directory -Path("image.jpg").unlink() +Path("needle.jpg").unlink() From b8c984f90ac8ce49ecead29dda5ba2790a2c8289 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 19 Mar 2025 15:36:36 +0100 Subject: [PATCH 9/9] Update comment --- examples/gallery/images/image.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/image.py b/examples/gallery/images/image.py index 3f86116eb77..49f0fe757fa 100644 --- a/examples/gallery/images/image.py +++ b/examples/gallery/images/image.py @@ -17,8 +17,9 @@ fig = pygmt.Figure() fig.basemap(region=[0, 2, 0, 2], projection="X10c", frame=True) -# Place and center ("+jCM") an image to the position ("+g") 1/1 on the current plot, -# scale it to a width of 8 centimeters ("+w") and draw a rectangular border around it +# Place and center ("+jCM") the image "needle.jpg" provided by GMT to the position +# ("+g") 1/1 on the current plot, scale it to a width of 8 centimeters ("+w") and draw +# a rectangular border around it fig.image( imagefile="https://oceania.generic-mapping-tools.org/cache/needle.jpg", position="g1/1+w8c+jCM",