Skip to content

Commit

Permalink
Alias clearance(C) for text
Browse files Browse the repository at this point in the history
  • Loading branch information
weiji14 committed Jun 19, 2020
1 parent 138617f commit 45a9858
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pygmt/base_plotting.py
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions pygmt/tests/test_text.py
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 45a9858

Please sign in to comment.