Skip to content

Commit

Permalink
Alias fill(G) for text
Browse files Browse the repository at this point in the history
  • Loading branch information
weiji14 committed Jun 19, 2020
1 parent 45a9858 commit 9b8e837
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 8 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", C="clearance", W="pen")
@use_alias(R="region", J="projection", B="frame", C="clearance", G="fill", W="pen")
@kwargs_to_strings(
R="sequence",
textfiles="sequence_space",
Expand Down Expand Up @@ -888,6 +888,13 @@ def text(
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.
fill : str
Sets the shade or color used for filling the text box [Default is
no fill]. Alternatively, use fill='c' to plot the text and then use
the text dimensions (and *clearance*) to build clip paths and turn
clipping on. This clipping can then be turned off later with clip
-C. To not plot the text but activate clipping, use fill='C'
instead.
pen : str
Sets the pen used to draw a rectangle around the text string
(see *clearance*) [Default is width = default, color = black,
Expand Down
Binary file added pygmt/tests/baseline/test_text_fill.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions pygmt/tests/test_text.py
Expand Up @@ -131,6 +131,23 @@ def test_text_font_bold(region, projection):
return fig


@pytest.mark.mpl_image_compare
def test_text_fill(region, projection):
"""
Print text with blue color fill
"""
fig = Figure()
fig.text(
region=region,
projection=projection,
x=1.2,
y=1.2,
text="blue fill around text",
fill="blue",
)
return fig


@pytest.mark.mpl_image_compare
def test_text_pen(region, projection):
"""
Expand Down

0 comments on commit 9b8e837

Please sign in to comment.