@@ -158,6 +158,39 @@ def test_imsave_color_alpha():
158
158
159
159
assert_array_equal (data , arr_buf )
160
160
161
+
162
+ @cleanup
163
+ def test_cursor_data ():
164
+ from matplotlib .backend_bases import MouseEvent
165
+
166
+ fig , ax = plt .subplots ()
167
+ im = ax .imshow (np .arange (100 ).reshape (10 , 10 ), origin = 'upper' )
168
+
169
+ x , y = 4 , 4
170
+ xdisp , ydisp = ax .transData .transform_point ([x , y ])
171
+
172
+ event = MouseEvent ('motion_notify_event' , fig .canvas , xdisp , ydisp )
173
+ assert im .get_zdata (event ) == 44
174
+
175
+ ax .clear ()
176
+ im = ax .imshow (np .arange (100 ).reshape (10 , 10 ), origin = 'lower' )
177
+
178
+ x , y = 4 , 4
179
+ xdisp , ydisp = ax .transData .transform_point ([x , y ])
180
+
181
+ event = MouseEvent ('motion_notify_event' , fig .canvas , xdisp , ydisp )
182
+ assert im .get_zdata (event ) == 44
183
+
184
+ fig , ax = plt .subplots ()
185
+ im = ax .imshow (np .arange (100 ).reshape (10 , 10 ), extent = [0 , 0.5 , 0 , 0.5 ])
186
+
187
+ x , y = 0.25 , 0.25
188
+ xdisp , ydisp = ax .transData .transform_point ([x , y ])
189
+
190
+ event = MouseEvent ('motion_notify_event' , fig .canvas , xdisp , ydisp )
191
+ assert im .get_zdata (event ) == 55
192
+
193
+
161
194
@image_comparison (baseline_images = ['image_clip' ])
162
195
def test_image_clip ():
163
196
from math import pi
0 commit comments