Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a gallery example of inset map showing a rectangle region #1020

Merged
merged 25 commits into from
Mar 12, 2021
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
749816d
Add a inset gallery
core-man Mar 8, 2021
a8ff9e7
Re-format
core-man Mar 8, 2021
7f516e7
Use np.array instead of temporal files
core-man Mar 8, 2021
11a1c95
Merge branch 'master' into inset-gallery
core-man Mar 9, 2021
54dc8f5
Use a list to plot the rectangle
core-man Mar 9, 2021
91c9b22
Apply suggestions from code review
core-man Mar 9, 2021
ecadf04
Explain r+s
core-man Mar 9, 2021
31a2be3
Merge branch 'master' into inset-gallery
core-man Mar 9, 2021
a61d561
Tiny update comments
core-man Mar 10, 2021
d8722f4
Fix
core-man Mar 10, 2021
f097459
Fix a bug
core-man Mar 10, 2021
0f736fb
Merge branch 'master' into inset-gallery
core-man Mar 10, 2021
c330bfd
Merge branch 'master' into inset-gallery
core-man Mar 10, 2021
afa8d9a
Merge branch 'master' into inset-gallery
core-man Mar 10, 2021
bea208e
Apply suggestions from code review
core-man Mar 11, 2021
5748ef7
Enlarge the inset region
core-man Mar 11, 2021
3b8651f
Use underscore for .py file name
core-man Mar 11, 2021
90c84ea
Delete duplicate .py file
core-man Mar 11, 2021
7552c6a
Merge branch 'master' into inset-gallery
core-man Mar 12, 2021
e7aa9da
Move inset_rectangle_region.py to embellishments dir
core-man Mar 12, 2021
4858d70
Apply suggestions from code review
core-man Mar 12, 2021
f60f4cd
Merge branch 'master' into inset-gallery
core-man Mar 12, 2021
0ea30e2
Use UTM instead of Mercator
core-man Mar 12, 2021
184a46e
Merge branch 'inset-gallery' of github.com:core-man/pygmt into inset-…
core-man Mar 12, 2021
218c321
Fix title
core-man Mar 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions examples/gallery/embellishments/inset_rectangle_region.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""
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,
box, offset, and margin can be customized. Plotting methods called within the
``with`` statement plot into the inset figure.
"""

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. 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 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 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. "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="U54S/?",
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()