Skip to content

Commit 45a9858

Browse files
committed
Alias clearance(C) for text
1 parent 138617f commit 45a9858

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

pygmt/base_plotting.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg
813813
lib.call_module("legend", arg_str)
814814

815815
@fmt_docstring
816-
@use_alias(R="region", J="projection", B="frame", W="pen")
816+
@use_alias(R="region", J="projection", B="frame", C="clearance", W="pen")
817817
@kwargs_to_strings(
818818
R="sequence",
819819
textfiles="sequence_space",
@@ -876,6 +876,18 @@ def text(
876876
input textfile(s) must have this as a column.
877877
{J}
878878
{R}
879+
clearance : str
880+
``[dx/dy][+to|O|c|C]``
881+
Adjust the clearance between the text and the surrounding box
882+
[15%]. Only used if *pen* or *fill* are specified. Append the unit
883+
you want ('c' for cm, 'i' for inch, or 'p' for point; if not given
884+
we consult 'PROJ_LENGTH_UNIT') or '%' for a percentage of the
885+
font size. Optionally, use modifier '+t' to set the shape of the
886+
textbox when using *fill* and/or *pen*. Append lower case 'o' to
887+
get a straight rectangle [Default]. Append upper case 'O' to get a
888+
rounded rectangle. In paragraph mode (*paragraph*) you can also
889+
append lower case 'c' to get a concave rectangle or append upper
890+
case 'C' to get a convex rectangle.
879891
pen : str
880892
Sets the pen used to draw a rectangle around the text string
881893
(see *clearance*) [Default is width = default, color = black,
Loading

pygmt/tests/test_text.py

+18
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,24 @@ def test_text_pen(region, projection):
148148
return fig
149149

150150

151+
@pytest.mark.mpl_image_compare
152+
def test_text_round_clearance(region, projection):
153+
"""
154+
Print text with round rectangle box clearance
155+
"""
156+
fig = Figure()
157+
fig.text(
158+
region=region,
159+
projection=projection,
160+
x=1.2,
161+
y=1.2,
162+
text="clearance around text",
163+
clearance="90%+tO",
164+
pen="default,black,dashed",
165+
)
166+
return fig
167+
168+
151169
@pytest.mark.mpl_image_compare
152170
def test_text_justify_bottom_right_and_top_left(region, projection):
153171
"""

0 commit comments

Comments
 (0)