Python Matplotlib MouseEvent xy 与 xydata
Python Matplotlib MouseEvent xy vs. xydata
我正在开发一个项目,使用 Python 3.4 和 Matplotlib 1.4.3 制作鼠标点击交互式像素图(使用 pyplot 创建)。我正在使用 matplotlib.backend_bases.MouseEvent class 使我的图形具有交互性。我才刚刚开始,到目前为止我有:
# Define an on_click() function that will print event data upon mouseclick
def on_click(event):
"""Print event data on mouseclick"""
print(event)
当我点击该图时,这是我得到的输出类型:
MPL 鼠标事件:xy=(289,265) xydata=(24.5956632653,21.9489795918) button=1 dblclick=False inaxes=Axes(0.141923,0.1;0.603077x0.8)
谁能告诉我xy部分是什么意思?这是一个 50x50 像素的地图,所以 xydata 是鼠标点击的像素位置。
分别是canvas
左边和下面的位置
the following attributes
x
- x position - pixels from left of canvas
y
- y position - pixels from bottom of canvas
canvas
- the FigureCanvas
instance generating the event
我正在开发一个项目,使用 Python 3.4 和 Matplotlib 1.4.3 制作鼠标点击交互式像素图(使用 pyplot 创建)。我正在使用 matplotlib.backend_bases.MouseEvent class 使我的图形具有交互性。我才刚刚开始,到目前为止我有:
# Define an on_click() function that will print event data upon mouseclick
def on_click(event):
"""Print event data on mouseclick"""
print(event)
当我点击该图时,这是我得到的输出类型:
MPL 鼠标事件:xy=(289,265) xydata=(24.5956632653,21.9489795918) button=1 dblclick=False inaxes=Axes(0.141923,0.1;0.603077x0.8)
谁能告诉我xy部分是什么意思?这是一个 50x50 像素的地图,所以 xydata 是鼠标点击的像素位置。
分别是canvas
左边和下面的位置
the following attributes
x
- x position - pixels from left of canvas
y
- y position - pixels from bottom of canvas
canvas
- theFigureCanvas
instance generating the event