You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Annotation.contains always calls get_window_extents() without setting
the renderer arg, which is thus None (and this is implicitly allowed by
the signature of get_window_extents), but get_window_extents calls
update_positions which *requires* a non-None renderer (it ultimately
calls renderer.points_to_pixels).
Instead, reuse the code from Text.get_window_extents() which defaults to
the artist-or-figure renderer if the arg is None.
Example breaking code:
from matplotlib import pyplot as plt
ann = plt.annotate(
"foo", (.5, .5), arrowprops={"arrowstyle": "->"},
textcoords="offset points", xytext=(10, 10))
plt.gcf().canvas.mpl_connect(
"button_press_event", lambda event: print(ann.contains(event)))
plt.show()
and click anywhere to trigger an AttributeError.
0 commit comments