简体   繁体   中英

How to extract 3d mouse coordinate on mouse click in Matplotlib in python?

The 3D mouse coordinates shows in the status bar of matplotlib window. But does anybody know how to get these coordinates from the status bar or using any function of matplotlib. 在此处输入图片说明

I don't know how you get your data, but I use this when I want the x,y from a image. In callback(event) you need event.zdata to also print the z value.

import matplotlib.pyplot as plt
import cv2

def callback(event):
        print event.xdata, event.ydata, event.zdata


img = cv2.imread(file)


fig, ax = plt.subplots() 

fig.canvas.callbacks.connect('button_press_event', callback)
plt.imshow(img,'gray')
plt.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM