Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance text with extra functionality and aliases #481

Merged
merged 16 commits into from Jun 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 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 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.
26 changes: 18 additions & 8 deletions pygmt/tests/test_text.py
Expand Up @@ -78,6 +78,16 @@ def test_text_input_single_filename():
return fig


@pytest.mark.mpl_image_compare
def test_text_input_external_filename():
"""
Run text by passing in an external filename to textfiles
weiji14 marked this conversation as resolved.
Show resolved Hide resolved
"""
fig = Figure()
fig.text(region=[0, 6.5, 0, 6.5], textfiles="@Table_5_11.txt")
return fig


@pytest.mark.mpl_image_compare
def test_text_input_multiple_filenames():
"""
Expand All @@ -100,13 +110,13 @@ def test_text_nonexistent_filename():
@pytest.mark.mpl_image_compare
def test_text_position(region):
"""
Print text at center middle and four corners (top left/right, bottom
left/right) of map.
Print text at center middle (CM) and eight other positions
(Top/Middle/Bottom x Left/Centre/Right).
"""
fig = Figure()
fig.text(region=region, projection="x1c", frame="a", position="CM", text="C M")
seisman marked this conversation as resolved.
Show resolved Hide resolved
for position in ("TL", "TR", "BL", "BR"):
fig.text(frame="a", position=position, text=position)
for position in ("TL", "TC", "TR", "ML", "MR", "BL", "BC", "BR"):
fig.text(position=position, text=position)
return fig


Expand All @@ -124,13 +134,13 @@ def test_text_xy_with_position_fails(region):
@pytest.mark.mpl_image_compare
def test_text_position_offset_with_line(region):
weiji14 marked this conversation as resolved.
Show resolved Hide resolved
"""
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.
Print text at centre middle (CM) and eight other positions
(Top/Middle/Bottom x Left/Centre/Right), 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="C M")
for position in ("TL", "TR", "BL", "BR"):
for position in ("TL", "TC", "TR", "ML", "MR", "BL", "BC", "BR"):
fig.text(position=position, text=position, offset="j0.5c+v")
return fig

Expand Down