-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Milestone
Description
Summary
AxesImage artists that have had a transform applied produce incorrect results for .contains(event). The current code only considers the artist's extent and does not adjust this to reflect any transform that has been applied.
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.transforms import Affine2D\
def on_press(event):
print("In image ", im.contains(event))
image = np.zeros((100,400,3), 'uint8') + [255, 0, 0]
fig, ax = plt.subplots()
ax.set_xlim(0,1000)
ax.set_ylim(0,1000)
rotationTransform = Affine2D().rotate_deg_around(200, 400, 90) + ax.transData
im = ax.imshow(image,extent=[0,400,350,450], transform = rotationTransform )
fig.canvas.mpl_connect('button_press_event', on_press)
plt.show()
Actual outcome
Click inside the top and bottom of the image and contains() returns False. Click outside the image but at its pre-transformed location and contains() returns True.
Expected outcome
Click inside the top and bottom of the image and contains() returns True. Click outside the image but at its pre-transformed location and contains() returns False.