Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

MouseEvent.x and .y have different types #11496

Copy link
Copy link
Closed
@tonyxty

Description

@tonyxty
Issue body actions

Bug report

Bug summary

MouseEvent.x is an int but MouseEvent.y is a float.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt


def onclick(event):
    print(event.x, event.y)
    print(type(event.x), type(event.y))


plt.imshow(np.zeros((32, 32)))
plt.gcf().canvas.mpl_connect('button_press_event', onclick)
plt.show()

Actual outcome

After randomly clicking on the image:

328 243.0
<class 'int'> <class 'numpy.float64'>
299 148.0
<class 'int'> <class 'numpy.float64'>
260 247.0
<class 'int'> <class 'numpy.float64'>

Expected outcome

328 243
<class 'int'> <class 'int'>
299 148
<class 'int'> <class 'int'>
260 247
<class 'int'> <class 'int'>

Matplotlib version

  • Operating system: Ubuntu 18.04
  • Matplotlib version: 2.2.2 (installed from pip)
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: Python 3.6.5
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueOpen a pull request against these issues if there are no active ones!Open a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.