From 749816d7f72496a0d3c4b4ea1c82904f40ff5991 Mon Sep 17 00:00:00 2001 From: core-man Date: Mon, 8 Mar 2021 13:52:17 +0800 Subject: [PATCH 01/17] Add a inset gallery --- examples/gallery/plot/inset-rectangle.py | 60 ++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 examples/gallery/plot/inset-rectangle.py diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py new file mode 100644 index 00000000000..f7347db1097 --- /dev/null +++ b/examples/gallery/plot/inset-rectangle.py @@ -0,0 +1,60 @@ +""" +Inset with an rectangle +------------------------ + +The :meth:`pygmt.Figure.inset` method adds an inset figure inside a larger +figure. The function is called using a ``with`` statement, and its position, +box, offset, and margin parameters are set. Plotting methods called within the +``with`` statement plot into the inset figure. +""" + +import numpy as np +import pygmt +from pygmt.helpers import GMTTempFile + +# Set the region to be near Tokyo +region = np.array([139.2, 140.5, 34.8, 36]) + +fig = pygmt.Figure() + +# Plot the base map of the primary figure +fig.basemap( + region=region, + projection="M12c", + frame=["WSne", "af"], +) + +# Set the land color to "lightbrown", the water to "azure1", the shorelines +# width to "2p", the smallest area to 1000 km2 for the primary figure +fig.coast( + land="lightbrown", + water="azure1", + shorelines="2p", + area_thresh=1000, +) + +# Create an inset, setting the position to bottom left, the width to +# 3 centimeters, the height to 3.6 centimeters, and the x- and y-offsets to +# 0.2 centimeters. Draws a rectangular box around the inset with a fill color +# of "white" and a pen of "1p". +with fig.inset(position="jBL+w3c/3.6c+o0.1c", box="+gwhite+p1p"): + # Plot the Japan main land in the inset using coast + # "M?" means Mercator projection with map width automatically determined + # based on the width in the position parameter of inset. + fig.coast( + region=[129, 146, 30, 46], + projection="M?", + dcw="JP+glightbrown+p0.2p", + area_thresh=10000, + ) + # Plot a rectangle in the inset map to show the area of the primary figure + with GMTTempFile() as temp_file: + with open(temp_file.name, "w") as f: + f.write("{} {} {} {}".format(region[0], region[2], region[1], region[3])) + fig.plot( + data=temp_file.name, + style="r+s", + pen="1p,blue", + ) + +fig.show() From a8ff9e7d764e429c2bdd05acbc47f353400d07c9 Mon Sep 17 00:00:00 2001 From: core-man Date: Mon, 8 Mar 2021 14:51:50 +0800 Subject: [PATCH 02/17] Re-format --- examples/gallery/plot/inset-rectangle.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py index f7347db1097..d9399d3e746 100644 --- a/examples/gallery/plot/inset-rectangle.py +++ b/examples/gallery/plot/inset-rectangle.py @@ -18,20 +18,11 @@ fig = pygmt.Figure() # Plot the base map of the primary figure -fig.basemap( - region=region, - projection="M12c", - frame=["WSne", "af"], -) +fig.basemap(region=region, projection="M12c", frame=["WSne", "af"]) # Set the land color to "lightbrown", the water to "azure1", the shorelines # width to "2p", the smallest area to 1000 km2 for the primary figure -fig.coast( - land="lightbrown", - water="azure1", - shorelines="2p", - area_thresh=1000, -) +fig.coast(land="lightbrown", water="azure1", shorelines="2p", area_thresh=1000) # Create an inset, setting the position to bottom left, the width to # 3 centimeters, the height to 3.6 centimeters, and the x- and y-offsets to @@ -51,10 +42,6 @@ with GMTTempFile() as temp_file: with open(temp_file.name, "w") as f: f.write("{} {} {} {}".format(region[0], region[2], region[1], region[3])) - fig.plot( - data=temp_file.name, - style="r+s", - pen="1p,blue", - ) + fig.plot(data=temp_file.name, style="r+s", pen="1p,blue") fig.show() From 7f516e7253ae4f219fd583d2b38810ce34887417 Mon Sep 17 00:00:00 2001 From: core-man Date: Mon, 8 Mar 2021 14:56:34 +0800 Subject: [PATCH 03/17] Use np.array instead of temporal files --- examples/gallery/plot/inset-rectangle.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py index d9399d3e746..8937d311db8 100644 --- a/examples/gallery/plot/inset-rectangle.py +++ b/examples/gallery/plot/inset-rectangle.py @@ -39,9 +39,7 @@ area_thresh=10000, ) # Plot a rectangle in the inset map to show the area of the primary figure - with GMTTempFile() as temp_file: - with open(temp_file.name, "w") as f: - f.write("{} {} {} {}".format(region[0], region[2], region[1], region[3])) - fig.plot(data=temp_file.name, style="r+s", pen="1p,blue") + rectangle = np.array([[region[0], region[2], region[1], region[3]]]) + fig.plot(data=rectangle, style="r+s", pen="1p,blue") fig.show() From 54dc8f5e5378eaa7c8ca143fbcd9f9037e28135b Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Tue, 9 Mar 2021 13:18:38 +0800 Subject: [PATCH 04/17] Use a list to plot the rectangle Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/plot/inset-rectangle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py index 8937d311db8..120a75d7dc5 100644 --- a/examples/gallery/plot/inset-rectangle.py +++ b/examples/gallery/plot/inset-rectangle.py @@ -39,7 +39,7 @@ area_thresh=10000, ) # Plot a rectangle in the inset map to show the area of the primary figure - rectangle = np.array([[region[0], region[2], region[1], region[3]]]) + rectangle = [[region[0], region[2], region[1], region[3]]] fig.plot(data=rectangle, style="r+s", pen="1p,blue") fig.show() From 91c9b221e7114d86fe48aecbd2a57dfc62b0ac99 Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Tue, 9 Mar 2021 14:47:27 +0800 Subject: [PATCH 05/17] Apply suggestions from code review Co-authored-by: Dongdong Tian --- examples/gallery/plot/inset-rectangle.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py index 120a75d7dc5..63ecbc65cd0 100644 --- a/examples/gallery/plot/inset-rectangle.py +++ b/examples/gallery/plot/inset-rectangle.py @@ -10,10 +10,9 @@ import numpy as np import pygmt -from pygmt.helpers import GMTTempFile # Set the region to be near Tokyo -region = np.array([139.2, 140.5, 34.8, 36]) +region = [139.2, 140.5, 34.8, 36] fig = pygmt.Figure() From ecadf0422b6d85f1b4b35980660d1a083f71e389 Mon Sep 17 00:00:00 2001 From: core-man Date: Tue, 9 Mar 2021 15:59:59 +0800 Subject: [PATCH 06/17] Explain r+s --- examples/gallery/plot/inset-rectangle.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py index 63ecbc65cd0..21356ba3e7a 100644 --- a/examples/gallery/plot/inset-rectangle.py +++ b/examples/gallery/plot/inset-rectangle.py @@ -28,16 +28,19 @@ # 0.2 centimeters. Draws a rectangular box around the inset with a fill color # of "white" and a pen of "1p". with fig.inset(position="jBL+w3c/3.6c+o0.1c", box="+gwhite+p1p"): - # Plot the Japan main land in the inset using coast - # "M?" means Mercator projection with map width automatically determined - # based on the width in the position parameter of inset. + # Plot the Japan main land in the inset using coast. "M?" means Mercator + # projection with map width automatically determined based on the width in + # the position parameter of inset fig.coast( region=[129, 146, 30, 46], projection="M?", dcw="JP+glightbrown+p0.2p", area_thresh=10000, ) - # Plot a rectangle in the inset map to show the area of the primary figure + # Plot a rectangle ("r") in the inset map to show the area of the primary figure. + # "+s" means that the first two columns are the longitude and latitude of + # the bottom left corner of the rectangle, and the last two columns the + # longitude and latitude of the uppper right corner. rectangle = [[region[0], region[2], region[1], region[3]]] fig.plot(data=rectangle, style="r+s", pen="1p,blue") From a61d561f103d71b19d7c90f27de8c99264b06b91 Mon Sep 17 00:00:00 2001 From: core-man Date: Wed, 10 Mar 2021 14:31:32 +0800 Subject: [PATCH 07/17] Tiny update comments --- examples/gallery/plot/inset-rectangle.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py index 21356ba3e7a..1217bf1aaa4 100644 --- a/examples/gallery/plot/inset-rectangle.py +++ b/examples/gallery/plot/inset-rectangle.py @@ -25,17 +25,19 @@ # Create an inset, setting the position to bottom left, the width to # 3 centimeters, the height to 3.6 centimeters, and the x- and y-offsets to -# 0.2 centimeters. Draws a rectangular box around the inset with a fill color +# 0.1 centimeters. Draws a rectangular box around the inset with a fill color # of "white" and a pen of "1p". with fig.inset(position="jBL+w3c/3.6c+o0.1c", box="+gwhite+p1p"): # Plot the Japan main land in the inset using coast. "M?" means Mercator # projection with map width automatically determined based on the width in - # the position parameter of inset + # the position parameter of inset. Highlight the Japan area in "lightbrown" + # and draw its outline with a pen of "0.2p". + draw polygon outlines (default is no outline) and +gfill to fill them fig.coast( region=[129, 146, 30, 46], projection="M?", dcw="JP+glightbrown+p0.2p", - area_thresh=10000, + area_thresh=1000, ) # Plot a rectangle ("r") in the inset map to show the area of the primary figure. # "+s" means that the first two columns are the longitude and latitude of From d8722f4dc4f41f243ac6e3fd8efdc917ef418c91 Mon Sep 17 00:00:00 2001 From: core-man Date: Wed, 10 Mar 2021 14:32:58 +0800 Subject: [PATCH 08/17] Fix --- examples/gallery/plot/inset-rectangle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py index 1217bf1aaa4..aca0a344ab0 100644 --- a/examples/gallery/plot/inset-rectangle.py +++ b/examples/gallery/plot/inset-rectangle.py @@ -37,7 +37,7 @@ region=[129, 146, 30, 46], projection="M?", dcw="JP+glightbrown+p0.2p", - area_thresh=1000, + area_thresh=10000, ) # Plot a rectangle ("r") in the inset map to show the area of the primary figure. # "+s" means that the first two columns are the longitude and latitude of From f0974599dc97e2f2866cea236d62a1643bdc7e53 Mon Sep 17 00:00:00 2001 From: core-man Date: Wed, 10 Mar 2021 14:34:32 +0800 Subject: [PATCH 09/17] Fix a bug --- examples/gallery/plot/inset-rectangle.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py index aca0a344ab0..6d1ecaf8e17 100644 --- a/examples/gallery/plot/inset-rectangle.py +++ b/examples/gallery/plot/inset-rectangle.py @@ -32,7 +32,6 @@ # projection with map width automatically determined based on the width in # the position parameter of inset. Highlight the Japan area in "lightbrown" # and draw its outline with a pen of "0.2p". - draw polygon outlines (default is no outline) and +gfill to fill them fig.coast( region=[129, 146, 30, 46], projection="M?", From bea208e2d50684bec6df04bb311a84ecd6696baa Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Thu, 11 Mar 2021 12:12:07 +0800 Subject: [PATCH 10/17] Apply suggestions from code review Co-authored-by: Dongdong Tian --- examples/gallery/plot/inset-rectangle.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py index 6d1ecaf8e17..cb8c5219e39 100644 --- a/examples/gallery/plot/inset-rectangle.py +++ b/examples/gallery/plot/inset-rectangle.py @@ -1,36 +1,36 @@ """ -Inset with an rectangle ------------------------- +Inset map showing a rectangle region +------------------------------------ The :meth:`pygmt.Figure.inset` method adds an inset figure inside a larger figure. The function is called using a ``with`` statement, and its position, -box, offset, and margin parameters are set. Plotting methods called within the +box, offset, and margin can be customized. Plotting methods called within the ``with`` statement plot into the inset figure. """ import numpy as np import pygmt -# Set the region to be near Tokyo +# Set the region of the main figure region = [139.2, 140.5, 34.8, 36] fig = pygmt.Figure() -# Plot the base map of the primary figure +# Plot the base map of the main figure fig.basemap(region=region, projection="M12c", frame=["WSne", "af"]) -# Set the land color to "lightbrown", the water to "azure1", the shorelines -# width to "2p", the smallest area to 1000 km2 for the primary figure +# Set the land color to "lightbrown", the water color to "azure1", the shorelines +# width to "2p", the area threshold to 1000 km^2 for the main figure fig.coast(land="lightbrown", water="azure1", shorelines="2p", area_thresh=1000) -# Create an inset, setting the position to bottom left, the width to -# 3 centimeters, the height to 3.6 centimeters, and the x- and y-offsets to +# Create an inset map, setting the position to bottom left, the width to +# 3 centimeters, the height to 3.6 centimeters, and the x- and y-offsets to # 0.1 centimeters. Draws a rectangular box around the inset with a fill color # of "white" and a pen of "1p". with fig.inset(position="jBL+w3c/3.6c+o0.1c", box="+gwhite+p1p"): # Plot the Japan main land in the inset using coast. "M?" means Mercator - # projection with map width automatically determined based on the width in - # the position parameter of inset. Highlight the Japan area in "lightbrown" + # projection with map width automatically determined from the inset width. + # Highlight the Japan area in "lightbrown" # and draw its outline with a pen of "0.2p". fig.coast( region=[129, 146, 30, 46], @@ -38,7 +38,7 @@ dcw="JP+glightbrown+p0.2p", area_thresh=10000, ) - # Plot a rectangle ("r") in the inset map to show the area of the primary figure. + # Plot a rectangle ("r") in the inset map to show the area of the main figure. # "+s" means that the first two columns are the longitude and latitude of # the bottom left corner of the rectangle, and the last two columns the # longitude and latitude of the uppper right corner. From 5748ef7c9a33ae2a6514b765c0eb46f01ce4196b Mon Sep 17 00:00:00 2001 From: core-man Date: Thu, 11 Mar 2021 15:19:33 +0800 Subject: [PATCH 11/17] Enlarge the inset region --- examples/gallery/plot/inset-rectangle.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py index cb8c5219e39..85a4e4f233a 100644 --- a/examples/gallery/plot/inset-rectangle.py +++ b/examples/gallery/plot/inset-rectangle.py @@ -12,7 +12,7 @@ import pygmt # Set the region of the main figure -region = [139.2, 140.5, 34.8, 36] +region = [137.5, 141, 34, 37] fig = pygmt.Figure() @@ -23,11 +23,11 @@ # width to "2p", the area threshold to 1000 km^2 for the main figure fig.coast(land="lightbrown", water="azure1", shorelines="2p", area_thresh=1000) -# Create an inset map, setting the position to bottom left, the width to +# Create an inset map, setting the position to bottom right, the width to # 3 centimeters, the height to 3.6 centimeters, and the x- and y-offsets to # 0.1 centimeters. Draws a rectangular box around the inset with a fill color # of "white" and a pen of "1p". -with fig.inset(position="jBL+w3c/3.6c+o0.1c", box="+gwhite+p1p"): +with fig.inset(position="jBR+w3c/3.6c+o0.1c", box="+gwhite+p1p"): # Plot the Japan main land in the inset using coast. "M?" means Mercator # projection with map width automatically determined from the inset width. # Highlight the Japan area in "lightbrown" @@ -43,6 +43,6 @@ # the bottom left corner of the rectangle, and the last two columns the # longitude and latitude of the uppper right corner. rectangle = [[region[0], region[2], region[1], region[3]]] - fig.plot(data=rectangle, style="r+s", pen="1p,blue") + fig.plot(data=rectangle, style="r+s", pen="2p,blue") fig.show() From 3b8651f4b29a15a0d3274772f963511555f5be19 Mon Sep 17 00:00:00 2001 From: core-man Date: Thu, 11 Mar 2021 15:20:21 +0800 Subject: [PATCH 12/17] Use underscore for .py file name --- examples/gallery/plot/inset_rectangle.py | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 examples/gallery/plot/inset_rectangle.py diff --git a/examples/gallery/plot/inset_rectangle.py b/examples/gallery/plot/inset_rectangle.py new file mode 100644 index 00000000000..85a4e4f233a --- /dev/null +++ b/examples/gallery/plot/inset_rectangle.py @@ -0,0 +1,48 @@ +""" +Inset map showing a rectangle region +------------------------------------ + +The :meth:`pygmt.Figure.inset` method adds an inset figure inside a larger +figure. The function is called using a ``with`` statement, and its position, +box, offset, and margin can be customized. Plotting methods called within the +``with`` statement plot into the inset figure. +""" + +import numpy as np +import pygmt + +# Set the region of the main figure +region = [137.5, 141, 34, 37] + +fig = pygmt.Figure() + +# Plot the base map of the main figure +fig.basemap(region=region, projection="M12c", frame=["WSne", "af"]) + +# Set the land color to "lightbrown", the water color to "azure1", the shorelines +# width to "2p", the area threshold to 1000 km^2 for the main figure +fig.coast(land="lightbrown", water="azure1", shorelines="2p", area_thresh=1000) + +# Create an inset map, setting the position to bottom right, the width to +# 3 centimeters, the height to 3.6 centimeters, and the x- and y-offsets to +# 0.1 centimeters. Draws a rectangular box around the inset with a fill color +# of "white" and a pen of "1p". +with fig.inset(position="jBR+w3c/3.6c+o0.1c", box="+gwhite+p1p"): + # Plot the Japan main land in the inset using coast. "M?" means Mercator + # projection with map width automatically determined from the inset width. + # Highlight the Japan area in "lightbrown" + # and draw its outline with a pen of "0.2p". + fig.coast( + region=[129, 146, 30, 46], + projection="M?", + dcw="JP+glightbrown+p0.2p", + area_thresh=10000, + ) + # Plot a rectangle ("r") in the inset map to show the area of the main figure. + # "+s" means that the first two columns are the longitude and latitude of + # the bottom left corner of the rectangle, and the last two columns the + # longitude and latitude of the uppper right corner. + rectangle = [[region[0], region[2], region[1], region[3]]] + fig.plot(data=rectangle, style="r+s", pen="2p,blue") + +fig.show() From 90c84ea7bc6f019235f3d804a05d658a64494f71 Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Fri, 12 Mar 2021 01:26:34 +0800 Subject: [PATCH 13/17] Delete duplicate .py file --- examples/gallery/plot/inset-rectangle.py | 48 ------------------------ 1 file changed, 48 deletions(-) delete mode 100644 examples/gallery/plot/inset-rectangle.py diff --git a/examples/gallery/plot/inset-rectangle.py b/examples/gallery/plot/inset-rectangle.py deleted file mode 100644 index 85a4e4f233a..00000000000 --- a/examples/gallery/plot/inset-rectangle.py +++ /dev/null @@ -1,48 +0,0 @@ -""" -Inset map showing a rectangle region ------------------------------------- - -The :meth:`pygmt.Figure.inset` method adds an inset figure inside a larger -figure. The function is called using a ``with`` statement, and its position, -box, offset, and margin can be customized. Plotting methods called within the -``with`` statement plot into the inset figure. -""" - -import numpy as np -import pygmt - -# Set the region of the main figure -region = [137.5, 141, 34, 37] - -fig = pygmt.Figure() - -# Plot the base map of the main figure -fig.basemap(region=region, projection="M12c", frame=["WSne", "af"]) - -# Set the land color to "lightbrown", the water color to "azure1", the shorelines -# width to "2p", the area threshold to 1000 km^2 for the main figure -fig.coast(land="lightbrown", water="azure1", shorelines="2p", area_thresh=1000) - -# Create an inset map, setting the position to bottom right, the width to -# 3 centimeters, the height to 3.6 centimeters, and the x- and y-offsets to -# 0.1 centimeters. Draws a rectangular box around the inset with a fill color -# of "white" and a pen of "1p". -with fig.inset(position="jBR+w3c/3.6c+o0.1c", box="+gwhite+p1p"): - # Plot the Japan main land in the inset using coast. "M?" means Mercator - # projection with map width automatically determined from the inset width. - # Highlight the Japan area in "lightbrown" - # and draw its outline with a pen of "0.2p". - fig.coast( - region=[129, 146, 30, 46], - projection="M?", - dcw="JP+glightbrown+p0.2p", - area_thresh=10000, - ) - # Plot a rectangle ("r") in the inset map to show the area of the main figure. - # "+s" means that the first two columns are the longitude and latitude of - # the bottom left corner of the rectangle, and the last two columns the - # longitude and latitude of the uppper right corner. - rectangle = [[region[0], region[2], region[1], region[3]]] - fig.plot(data=rectangle, style="r+s", pen="2p,blue") - -fig.show() From e7aa9dade71f59c977cac377e0c6928751e6b44d Mon Sep 17 00:00:00 2001 From: core-man Date: Fri, 12 Mar 2021 14:05:07 +0800 Subject: [PATCH 14/17] Move inset_rectangle_region.py to embellishments dir --- .../inset_rectangle_region.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/gallery/{plot/inset_rectangle.py => embellishments/inset_rectangle_region.py} (100%) diff --git a/examples/gallery/plot/inset_rectangle.py b/examples/gallery/embellishments/inset_rectangle_region.py similarity index 100% rename from examples/gallery/plot/inset_rectangle.py rename to examples/gallery/embellishments/inset_rectangle_region.py From 4858d700d9989d4500c72bd393355ffd7ed05854 Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Fri, 12 Mar 2021 15:55:20 +0800 Subject: [PATCH 15/17] Apply suggestions from code review Co-authored-by: Michael Grund --- .../gallery/embellishments/inset_rectangle_region.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/gallery/embellishments/inset_rectangle_region.py b/examples/gallery/embellishments/inset_rectangle_region.py index 85a4e4f233a..3deb2d8cd79 100644 --- a/examples/gallery/embellishments/inset_rectangle_region.py +++ b/examples/gallery/embellishments/inset_rectangle_region.py @@ -8,7 +8,6 @@ ``with`` statement plot into the inset figure. """ -import numpy as np import pygmt # Set the region of the main figure @@ -19,13 +18,13 @@ # Plot the base map of the main figure fig.basemap(region=region, projection="M12c", frame=["WSne", "af"]) -# Set the land color to "lightbrown", the water color to "azure1", the shorelines -# width to "2p", the area threshold to 1000 km^2 for the main figure +# Set the land color to "lightbrown", the water color to "azure1", the shoreline +# width to "2p", and the area threshold to 1000 km^2 for the main figure fig.coast(land="lightbrown", water="azure1", shorelines="2p", area_thresh=1000) # Create an inset map, setting the position to bottom right, the width to -# 3 centimeters, the height to 3.6 centimeters, and the x- and y-offsets to -# 0.1 centimeters. Draws a rectangular box around the inset with a fill color +# 3 cm, the height to 3.6 cm, and the x- and y-offsets to +# 0.1 cm, respectively. Draws a rectangular box around the inset with a fill color # of "white" and a pen of "1p". with fig.inset(position="jBR+w3c/3.6c+o0.1c", box="+gwhite+p1p"): # Plot the Japan main land in the inset using coast. "M?" means Mercator From 0ea30e2a88c6e67c846fb785fce5b8c67614988f Mon Sep 17 00:00:00 2001 From: core-man Date: Fri, 12 Mar 2021 18:31:35 +0800 Subject: [PATCH 16/17] Use UTM instead of Mercator --- .../gallery/embellishments/inset_rectangle_region.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/gallery/embellishments/inset_rectangle_region.py b/examples/gallery/embellishments/inset_rectangle_region.py index 85a4e4f233a..8cec2d5a6b7 100644 --- a/examples/gallery/embellishments/inset_rectangle_region.py +++ b/examples/gallery/embellishments/inset_rectangle_region.py @@ -16,8 +16,9 @@ fig = pygmt.Figure() -# Plot the base map of the main figure -fig.basemap(region=region, projection="M12c", frame=["WSne", "af"]) +# Plot the base map of the main figure. Universal Transverse Mercator (UTM) projection +# is used and the UTM zone is set to be "54S". +fig.basemap(region=region, projection="U54S/12c", frame=["WSne", "af"]) # Set the land color to "lightbrown", the water color to "azure1", the shorelines # width to "2p", the area threshold to 1000 km^2 for the main figure @@ -28,13 +29,13 @@ # 0.1 centimeters. Draws a rectangular box around the inset with a fill color # of "white" and a pen of "1p". with fig.inset(position="jBR+w3c/3.6c+o0.1c", box="+gwhite+p1p"): - # Plot the Japan main land in the inset using coast. "M?" means Mercator + # Plot the Japan main land in the inset using coast. "U54S/M?" means UTM # projection with map width automatically determined from the inset width. # Highlight the Japan area in "lightbrown" # and draw its outline with a pen of "0.2p". fig.coast( region=[129, 146, 30, 46], - projection="M?", + projection="U54S/?", dcw="JP+glightbrown+p0.2p", area_thresh=10000, ) From 218c321afea990ec24e63c1026fdd5bdd49c2f54 Mon Sep 17 00:00:00 2001 From: Yao Jiayuan Date: Fri, 12 Mar 2021 19:01:03 +0800 Subject: [PATCH 17/17] Fix title Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/embellishments/inset_rectangle_region.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/inset_rectangle_region.py b/examples/gallery/embellishments/inset_rectangle_region.py index f04db6915db..a30b770f20e 100644 --- a/examples/gallery/embellishments/inset_rectangle_region.py +++ b/examples/gallery/embellishments/inset_rectangle_region.py @@ -1,6 +1,6 @@ """ -Inset map showing a rectangle region ------------------------------------- +Inset map showing a rectangular region +-------------------------------------- The :meth:`pygmt.Figure.inset` method adds an inset figure inside a larger figure. The function is called using a ``with`` statement, and its position,