8000 Log pixel coordinates in event_handling coords_demo example · matplotlib/matplotlib@8955d02 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8955d02

Browse files
committed
Log pixel coordinates in event_handling coords_demo example
1 parent df12d8c commit 8955d02

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/event_handling/coords_demo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818

1919

2020
def on_move(event):
21-
# get the x and y pixel coords
22-
x, y = event.x, event.y
2321
if event.inaxes:
22+
# get the x and y pixel coords
23+
x, y = event.x, event.y
2424
ax = event.inaxes # the axes instance
25-
print('data coords %f %f' % (event.xdata, event.ydata))
25+
print('data coords %f %f, pixel coords %f %f'
26+
% (event.xdata, event.ydata, x, y))
2627

2728

2829
def on_click(event):

0 commit comments

Comments
 (0)
0