Skip to content

Commit 7fde6c6

Browse files
committed
Add centre-middle text to set up map frame first
So that we don't plot the map frame four times in a loop.
1 parent ada1f6d commit 7fde6c6

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed
8 KB
Loading
Binary file not shown.
Loading

pygmt/tests/test_text.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ def test_text_nonexistent_filename():
100100
@pytest.mark.mpl_image_compare
101101
def test_text_position_four_corners(region):
102102
"""
103-
Print text at four corners (top left/right, bottom left/right) of map.
103+
Print text at center middle and four corners (top left/right, bottom
104+
left/right) of map.
104105
"""
105106
fig = Figure()
107+
fig.text(region=region, projection="x1c", frame="a", position="CM", text="CM")
106108
for position in ("TL", "TR", "BL", "BR"):
107-
fig.text(
108-
region=region, projection="x1c", frame="a", position=position, text=position
109-
)
109+
fig.text(frame="a", position=position, text=position)
110110
return fig
111111

112112

@@ -124,19 +124,14 @@ def test_text_xy_with_position_fails(region, projection):
124124
@pytest.mark.mpl_image_compare
125125
def test_text_position_offset_with_line(region):
126126
"""
127-
Print text at four corners (top left/right, bottom left/right) of map,
128-
offset by 0.5 cm, with a line drawn from the original to the shifted point.
127+
Print text at centre middle and four corners (top left/right, bottom
128+
left/right) of map, offset by 0.5 cm, with a line drawn from the original
129+
to the shifted point.
129130
"""
130131
fig = Figure()
132+
fig.text(region=region, projection="x1c", frame="a", position="CM", text="CM")
131133
for position in ("TL", "TR", "BL", "BR"):
132-
fig.text(
133-
region=region,
134-
projection="x1c",
135-
frame="a",
136-
position=position,
137-
text=position,
138-
offset="j0.5c+v",
139-
)
134+
fig.text(position=position, text=position, offset="j0.5c+v")
140135
return fig
141136

142137

0 commit comments

Comments
 (0)