Skip to content

Commit 493e6b2

Browse files
committed
Update Figure.inset in examples/gallery/embellishments/inset.py to the Pythonic syntax
1 parent c5d10d4 commit 493e6b2

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

examples/gallery/embellishments/inset.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,32 @@
22
Inset
33
=====
44
5-
The :meth:`pygmt.Figure.inset` method adds an inset figure inside a larger
6-
figure. The method is called using a ``with`` statement, and its ``position``,
7-
``box``, ``offset``, and ``clearance`` parameters are set. Plotting methods
8-
called within the ``with`` statement are applied to the inset figure.
5+
The :meth:`pygmt.Figure.inset` method adds an inset figure inside a larger figure. The
6+
method is called using a ``with`` statement. Plotting methods called within the ``with``
7+
statement are applied to the inset figure.
98
"""
109

1110
# %%
1211
import pygmt
13-
from pygmt.params import Box
12+
from pygmt.params import Box, Position
1413

1514
fig = pygmt.Figure()
16-
# Create the primary figure, setting the region to Madagascar, the land color
17-
# to "brown", the water to "lightblue", the shorelines width to "thin", and
18-
# adding a frame
15+
# Create the primary figure, setting the region to Madagascar, the land color to
16+
# "brown", the water to "lightblue", the shorelines width to "thin", and adding a frame
1917
fig.coast(region="MG+r2", land="brown", water="lightblue", shorelines="thin", frame="a")
2018
# Create an inset, placing it in the Top Left (TL) corner with a width of 3.5 cm and
2119
# x- and y-offsets of 0.2 cm. The clearance is set to 0, and the border is "gold" with a
2220
# pen size of 1.5 points.
23-
with fig.inset(position="jTL+w3.5c+o0.2c", clearance=0, box=Box(pen="1.5p,gold")):
21+
with fig.inset(
22+
position=Position("TL", offset=0.2),
23+
width=3.5,
24+
clearance=0,
25+
box=Box(pen="1.5p,gold"),
26+
):
2427
# Create a figure in the inset using coast. This example uses the azimuthal
25-
# orthogonal projection centered at 47E, 20S. The land color is set to
26-
# "gray" and Madagascar is highlighted in "red3".
28+
# orthogonal projection centered at 47E, 20S. The land color is set to "gray" and
29+
# Madagascar is highlighted in "red3".
2730
fig.coast(
28-
region="g",
29-
projection="G47/-20/?",
30-
land="gray",
31-
water="white",
32-
dcw="MG+gred3",
31+
region="g", projection="G47/-20/?", land="gray", water="white", dcw="MG+gred3"
3332
)
3433
fig.show()

0 commit comments

Comments
 (0)