Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f6e3edc

Browse filesBrowse files
committed
added test for Annotation.set_position
1 parent 38b9385 commit f6e3edc
Copy full SHA for f6e3edc

File tree

1 file changed

+31
-0
lines changed
Filter options

1 file changed

+31
-0
lines changed

‎lib/matplotlib/tests/test_text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_text.py
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,34 @@ def test_alignment():
194194
ax.set_ylim([0, 1.5])
195195
ax.set_xticks([])
196196
ax.set_yticks([])
197+
198+
199+
@cleanup
200+
def test_set_position():
201+
fig, ax = plt.subplots()
202+
203+
# test set_position
204+
ann = ax.annotate('test', (0, 0), xytext=(0, 0), textcoords='figure pixels')
205+
plt.draw()
206+
207+
init_pos = ann.get_window_extent(fig.canvas.renderer)
208+
shift_val = 15
209+
ann.set_position((shift_val, shift_val))
210+
plt.draw()
211+
post_pos = ann.get_window_extent(fig.canvas.renderer)
212+
213+
for a, b in zip(init_pos.min, post_pos.min):
214+
assert a + shift_val == b
215+
216+
# test xyann
217+
ann = ax.annotate('test', (0, 0), xytext=(0, 0), textcoords='figure pixels')
218+
plt.draw()
219+
220+
init_pos = ann.get_window_extent(fig.canvas.renderer)
221+
shift_val = 15
222+
ann.xyann = (shift_val, shift_val)
223+
plt.draw()
224+
post_pos = ann.get_window_extent(fig.canvas.renderer)
225+
226+
for a, b in zip(init_pos.min, post_pos.min):
227+
assert a + shift_val == b

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.