Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: QuadMesh get_cursor_data errors if no array is set #22908

Closed
raphaelquast opened this issue Apr 26, 2022 · 1 comment · Fixed by #22907
Closed

[Bug]: QuadMesh get_cursor_data errors if no array is set #22908

raphaelquast opened this issue Apr 26, 2022 · 1 comment · Fixed by #22907
Milestone

Comments

@raphaelquast
Copy link
Contributor

Bug summary

This is just a very minor bug I noticed...

When using a QuadMesh without setting an array, the get_cursor_data function throws an error because it does not check if an array has been set.

This is somewhat connected to #22334 but this is just about the case when no array has been set.

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.collections import QuadMesh
import numpy as np

x, y = np.linspace([-1.5, -1.5], [1.5, 1.5], 20).T
X, Y = np.meshgrid(x, y)

coll = QuadMesh(np.stack((X, Y), axis=2))
f, ax = plt.subplots()
ax.add_collection(coll)

Actual outcome

TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "...\matplotlib\cbook\__init__.py", line 287, in process
    func(*args, **kwargs)
  File "...\matplotlib\backend_bases.py", line 3061, in mouse_move
    s = self._mouse_event_to_message(event)
  File "...\matplotlib\backend_bases.py", line 3051, in _mouse_event_to_message
    data = a.get_cursor_data(event)
  File "...\matplotlib\collections.py", line 2214, in get_cursor_data
    return self.get_array()[ind]
TypeError: 'NoneType' object is not 

Expected outcome

no error

Additional information

No response

Operating system

No response

Matplotlib Version

3.5.1

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

No response

@raphaelquast
Copy link
Contributor Author

raphaelquast commented Apr 26, 2022

here's a quick project to fix it: #22907

@tacaswell tacaswell added this to the v3.5.2 milestone Apr 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants