|
2 | 2 | Inset |
3 | 3 | ===== |
4 | 4 |
|
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. |
9 | 8 | """ |
10 | 9 |
|
11 | 10 | # %% |
12 | 11 | import pygmt |
13 | | -from pygmt.params import Box |
| 12 | +from pygmt.params import Box, Position |
14 | 13 |
|
15 | 14 | 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 |
19 | 17 | fig.coast(region="MG+r2", land="brown", water="lightblue", shorelines="thin", frame="a") |
20 | 18 | # Create an inset, placing it in the Top Left (TL) corner with a width of 3.5 cm and |
21 | 19 | # x- and y-offsets of 0.2 cm. The clearance is set to 0, and the border is "gold" with a |
22 | 20 | # 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 | +): |
24 | 27 | # 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". |
27 | 30 | 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" |
33 | 32 | ) |
34 | 33 | fig.show() |
0 commit comments