Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a91945

Browse files
committed
Add test for data cursor on transformed image
1 parent 12fbe4a commit 7a91945

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/matplotlib/tests/test_image.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,15 @@ def test_cursor_data():
324324
event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp)
325325
assert im.get_cursor_data(event) is None
326326

327+
# Now try with additional transform applied to the image artist
328+
trans = Affine2D().scale(2).rotate(0.5)
329+
im = ax.imshow(np.arange(100).reshape(10, 10),
330+
transform=trans + ax.transData)
331+
x, y = 3, 10
332+
xdisp, ydisp = ax.transData.transform([x, y])
333+
event = MouseEvent('motion_notify_event', fig.canvas, xdisp, ydisp)
334+
assert im.get_cursor_data(event) == 44
335+
327336

328337
@pytest.mark.parametrize(
329338
"data, text_without_colorbar, text_with_colorbar", [

0 commit comments

Comments
 (0)