Skip to content

Commit 626a734

Browse files
Figure.inset: Deprecate parameter margin to clearance (Will be removed in v0.20.0) (#4296)
1 parent 530c11d commit 626a734

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

examples/gallery/embellishments/inset.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
=====
44
55
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
7-
``position``, ``box``, ``offset``, and ``margin`` parameters are set. Plotting
8-
methods called within the ``with`` statement are applied to the inset figure.
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.
99
"""
1010

1111
# %%
@@ -18,9 +18,9 @@
1818
# adding a frame
1919
fig.coast(region="MG+r2", land="brown", water="lightblue", shorelines="thin", frame="a")
2020
# Create an inset, placing it in the Top Left (TL) corner with a width of 3.5 cm and
21-
# x- and y-offsets of 0.2 cm. The margin is set to 0, and the border is "gold" with a
21+
# x- and y-offsets of 0.2 cm. The clearance is set to 0, and the border is "gold" with a
2222
# pen size of 1.5 points.
23-
with fig.inset(position="jTL+w3.5c+o0.2c", margin=0, box=Box(pen="1.5p,gold")):
23+
with fig.inset(position="jTL+w3.5c+o0.2c", clearance=0, box=Box(pen="1.5p,gold")):
2424
# Create a figure in the inset using coast. This example uses the azimuthal
2525
# orthogonal projection centered at 47E, 20S. The land color is set to
2626
# "gray" and Madagascar is highlighted in "red3".

examples/gallery/embellishments/inset_rectangle_region.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
======================================
44
55
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
7-
``position``, ``box``, ``offset``, and ``margin`` can be customized. Plotting
8-
methods called within the ``with`` statement plot into the inset figure.
6+
figure. The method is called using a ``with`` statement, and its ``position``,
7+
``box``, ``offset``, and ``clearance`` can be customized. Plotting methods
8+
called within the ``with`` statement plot into the inset figure.
99
"""
1010

1111
# %%

pygmt/src/inset.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@
88

99
from pygmt.alias import Alias, AliasSystem
1010
from pygmt.clib import Session
11-
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias
11+
from pygmt.helpers import (
12+
build_arg_list,
13+
deprecate_parameter,
14+
fmt_docstring,
15+
kwargs_to_strings,
16+
use_alias,
17+
)
1218
from pygmt.params import Box
1319

1420
__doctest_skip__ = ["inset"]
1521

1622

1723
@fmt_docstring
24+
@deprecate_parameter("margin", "clearance", "v0.18.0", remove_version="v0.20.0")
1825
@contextlib.contextmanager
19-
@use_alias(D="position", M="margin")
26+
@use_alias(D="position", C="clearance")
2027
@kwargs_to_strings(D="sequence", M="sequence")
2128
def inset(
2229
self,
@@ -90,7 +97,7 @@ def inset(
9097
box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box appearance,
9198
pass a :class:`pygmt.params.Box` object to control style, fill, pen, and other
9299
box properties.
93-
margin : float, str, or list
100+
clearance : float, str, or list
94101
This is clearance that is added around the inside of the inset.
95102
Plotting will take place within the inner region only. The margins
96103
can be a single value, a pair of values separated (for setting
@@ -116,7 +123,7 @@ def inset(
116123
>>> fig.coast(region="MG+r2", water="lightblue", shorelines="thin")
117124
>>> # Use a "with" statement to initialize the inset context manager
118125
>>> # Setting the position to Top Left and a width of 3.5 centimeters
119-
>>> with fig.inset(position="jTL+w3.5c+o0.2c", margin=0, box=Box(pen="green")):
126+
>>> with fig.inset(position="jTL+w3.5c+o0.2c", clearance=0, box=Box(pen="green")):
120127
... # Map elements under the "with" statement are plotted in the inset
121128
... fig.coast(
122129
... region="g",

pygmt/tests/test_inset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_inset_aliases():
1515
"""
1616
fig = Figure()
1717
fig.basemap(region="MG+r2", frame="afg")
18-
with fig.inset(position="jTL+w3.5c+o0.2c", margin=0, box=Box(pen="green")):
18+
with fig.inset(position="jTL+w3.5c+o0.2c", clearance=0, box=Box(pen="green")):
1919
fig.basemap(region="g", projection="G47/-20/4c", frame="afg")
2020
return fig
2121

@@ -28,7 +28,7 @@ def test_inset_context_manager():
2828
"""
2929
fig = Figure()
3030
fig.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True)
31-
with fig.inset(position="jBL+w3c+o0.2c", margin=0, box=Box(pen="black")):
31+
with fig.inset(position="jBL+w3c+o0.2c", clearance=0, box=Box(pen="black")):
3232
fig.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg")
3333
fig.basemap(rose="jTR+w3c") # Pass rose argument with basemap after the inset
3434
return fig

0 commit comments

Comments
 (0)