Skip to content

Commit

Permalink
Add centre-middle text to set up map frame first
Browse files Browse the repository at this point in the history
So that we don't plot the map frame four times in a loop.
  • Loading branch information
weiji14 committed Jun 20, 2020
1 parent ada1f6d commit 7fde6c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
Binary file added pygmt/tests/baseline/test_text_position.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified pygmt/tests/baseline/test_text_position_offset_with_line.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 9 additions & 14 deletions pygmt/tests/test_text.py
Expand Up @@ -100,13 +100,13 @@ def test_text_nonexistent_filename():
@pytest.mark.mpl_image_compare
def test_text_position_four_corners(region):
"""
Print text at four corners (top left/right, bottom left/right) of map.
Print text at center middle and four corners (top left/right, bottom
left/right) of map.
"""
fig = Figure()
fig.text(region=region, projection="x1c", frame="a", position="CM", text="CM")
for position in ("TL", "TR", "BL", "BR"):
fig.text(
region=region, projection="x1c", frame="a", position=position, text=position
)
fig.text(frame="a", position=position, text=position)
return fig


Expand All @@ -124,19 +124,14 @@ def test_text_xy_with_position_fails(region, projection):
@pytest.mark.mpl_image_compare
def test_text_position_offset_with_line(region):
"""
Print text at four corners (top left/right, bottom left/right) of map,
offset by 0.5 cm, with a line drawn from the original to the shifted point.
Print text at centre middle and four corners (top left/right, bottom
left/right) of map, offset by 0.5 cm, with a line drawn from the original
to the shifted point.
"""
fig = Figure()
fig.text(region=region, projection="x1c", frame="a", position="CM", text="CM")
for position in ("TL", "TR", "BL", "BR"):
fig.text(
region=region,
projection="x1c",
frame="a",
position=position,
text=position,
offset="j0.5c+v",
)
fig.text(position=position, text=position, offset="j0.5c+v")
return fig


Expand Down

0 comments on commit 7fde6c6

Please sign in to comment.