diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index dc076a39bba..1b136e588c5 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -813,7 +813,7 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg lib.call_module("legend", arg_str) @fmt_docstring - @use_alias(R="region", J="projection", B="frame", W="pen") + @use_alias(R="region", J="projection", B="frame", C="clearance", W="pen") @kwargs_to_strings( R="sequence", textfiles="sequence_space", @@ -876,6 +876,18 @@ def text( input textfile(s) must have this as a column. {J} {R} + clearance : str + ``[dx/dy][+to|O|c|C]`` + Adjust the clearance between the text and the surrounding box + [15%]. Only used if *pen* or *fill* are specified. Append the unit + you want ('c' for cm, 'i' for inch, or 'p' for point; if not given + we consult 'PROJ_LENGTH_UNIT') or '%' for a percentage of the + font size. Optionally, use modifier '+t' to set the shape of the + textbox when using *fill* and/or *pen*. Append lower case 'o' to + get a straight rectangle [Default]. Append upper case 'O' to get a + rounded rectangle. In paragraph mode (*paragraph*) you can also + append lower case 'c' to get a concave rectangle or append upper + case 'C' to get a convex rectangle. pen : str Sets the pen used to draw a rectangle around the text string (see *clearance*) [Default is width = default, color = black, diff --git a/pygmt/tests/baseline/test_text_round_clearance.png b/pygmt/tests/baseline/test_text_round_clearance.png new file mode 100644 index 00000000000..c35e44a5d74 Binary files /dev/null and b/pygmt/tests/baseline/test_text_round_clearance.png differ diff --git a/pygmt/tests/test_text.py b/pygmt/tests/test_text.py index 88e7f8e9792..930a6d19f72 100644 --- a/pygmt/tests/test_text.py +++ b/pygmt/tests/test_text.py @@ -148,6 +148,24 @@ def test_text_pen(region, projection): return fig +@pytest.mark.mpl_image_compare +def test_text_round_clearance(region, projection): + """ + Print text with round rectangle box clearance + """ + fig = Figure() + fig.text( + region=region, + projection=projection, + x=1.2, + y=1.2, + text="clearance around text", + clearance="90%+tO", + pen="default,black,dashed", + ) + return fig + + @pytest.mark.mpl_image_compare def test_text_justify_bottom_right_and_top_left(region, projection): """