Skip to content

Commit c3ac955

Browse files
inset: Add aliases for R and J and fix two examples (#1931)
Co-authored-by: Michael Grund <[email protected]>
1 parent 37ab418 commit c3ac955

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

examples/gallery/embellishments/inset_rectangle_region.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@
2424
# figure
2525
fig.coast(land="lightbrown", water="azure1", shorelines="2p", area_thresh=1000)
2626

27-
# Create an inset map, setting the position to bottom right, the width to
28-
# 3 cm, the height to 3.6 cm, and the x- and y-offsets to
29-
# 0.1 cm, respectively. Draws a rectangular box around the inset with a fill
30-
# color of "white" and a pen of "1p".
31-
with fig.inset(position="jBR+w3c/3.6c+o0.1c", box="+gwhite+p1p"):
32-
# Plot the Japan main land in the inset using coast. "U54S/?" means UTM
33-
# projection with map width automatically determined from the inset width.
27+
# Create an inset map, setting the position to bottom right, and the x- and
28+
# y-offsets to 0.1 cm, respectively.
29+
# The inset map contains the Japan main land. "U54S/3c" means UTM projection
30+
# with a map width of 3 cm. The inset width and height are automatically
31+
# calculated from the specified ``region`` and ``projection`` parameters.
32+
# Draws a rectangular box around the inset with a fill color of "white" and
33+
# a pen of "1p".
34+
with fig.inset(
35+
position="jBR+o0.1c",
36+
box="+gwhite+p1p",
37+
region=[129, 146, 30, 46],
38+
projection="U54S/3c",
39+
):
3440
# Highlight the Japan area in "lightbrown"
3541
# and draw its outline with a pen of "0.2p".
3642
fig.coast(
37-
region=[129, 146, 30, 46],
38-
projection="U54S/?",
3943
dcw="JP+glightbrown+p0.2p",
4044
area_thresh=10000,
4145
)

examples/tutorials/advanced/insets.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,16 @@
9797
frame="a",
9898
)
9999
# This does not include an inset fill as it is covered by the inset figure
100-
with fig.inset(position="jBL+w3c+o0.5c/0.2c", box="+pblack"):
101-
# Use a plotting function to create a figure inside the inset
100+
# Inset width/height are determined by the ``region`` and ``projection``
101+
# parameters.
102+
with fig.inset(
103+
position="jBL+o0.5c/0.2c",
104+
box="+pblack",
105+
region=[-80, -65, 35, 50],
106+
projection="M3c",
107+
):
108+
# Use a plotting function to create a figure inside the inset.
102109
fig.coast(
103-
region=[-80, -65, 35, 50],
104-
projection="M3c",
105110
land="gray",
106111
borders=[1, 2],
107112
shorelines="1/thin",

pygmt/src/inset.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@
1111

1212
@fmt_docstring
1313
@contextlib.contextmanager
14-
@use_alias(D="position", F="box", M="margin", N="no_clip", V="verbose")
15-
@kwargs_to_strings(D="sequence", M="sequence")
14+
@use_alias(
15+
D="position",
16+
F="box",
17+
J="projection",
18+
M="margin",
19+
N="no_clip",
20+
R="region",
21+
V="verbose",
22+
)
23+
@kwargs_to_strings(D="sequence", M="sequence", R="sequence")
1624
def inset(self, **kwargs):
1725
r"""
1826
Create an inset figure to be placed within a larger figure.
@@ -39,7 +47,7 @@ def inset(self, **kwargs):
3947
4048
Append **g**\ *lon*/*lat* for map (user) coordinates,
4149
**j**\ *code* or **J**\ *code* for setting the *refpoint* via a
42-
2-char justification code \ that refers to the (invisible)
50+
2-char justification code that refers to the (invisible)
4351
projected map bounding box, **n**\ *xn*/*yn* for normalized (0-1)
4452
bounding box coordinates, or **x**\ *x*/*y* for plot
4553
coordinates (inches, cm, points, append unit).
@@ -98,6 +106,8 @@ def inset(self, **kwargs):
98106
no_clip : bool
99107
Do NOT clip features extruding outside map inset boundaries [Default
100108
is clip].
109+
{R}
110+
{J}
101111
{V}
102112
103113
Examples

0 commit comments

Comments
 (0)