Skip to content

Fix quad mesh cursor data #22907

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

Merged
merged 3 commits into from
Apr 30, 2022

Conversation

raphaelquast
Copy link
Contributor

@raphaelquast raphaelquast commented Apr 26, 2022

PR Summary

Closes: #22908

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.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@oscargus oscargus added the status: needs workflow approval For PRs from new contributors, from which GitHub blocks workflows by default. label Apr 29, 2022
@oscargus
Copy link
Member

I took the liberty of editing your post to point out the issue number. In this way, Github links this PR and the issue and the issue will be automatically closed when this is merged.

@raphaelquast
Copy link
Contributor Author

@oscargus perfect, thanks! I don't have the rights to merge anything so this needs to be done by one of your devs as well!

@QuLogic QuLogic added this to the v3.5.2 milestone Apr 30, 2022
@QuLogic QuLogic merged commit 89b21b5 into matplotlib:main Apr 30, 2022
@QuLogic
Copy link
Member

QuLogic commented Apr 30, 2022

meeseeksdev backport to v3.5.x

@QuLogic
Copy link
Member

QuLogic commented Apr 30, 2022

Thanks @raphaelquast! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again.

QuLogic added a commit that referenced this pull request Apr 30, 2022
…907-on-v3.5.x

Backport PR #22907 on branch v3.5.x (Fix quad mesh cursor data)
@greglucas
Copy link
Contributor

I don't think this was quite right because get_array() often returns a numpy array, which when evaluated with if array raises a ValueError.

Hover the cursor over the figure in this example:

import matplotlib.pyplot as plt
import numpy as np
n = 4
x = np.arange(n)
X = x[:, None] * x[None, :]

fig, ax = plt.subplots()
mesh = ax.pcolormesh(X)
mesh.set_mouseover(True)

plt.show()

@raphaelquast
Copy link
Contributor Author

@greglucas sorry... indeed that's not the desired behavior!

I opened a new pull request to fix this. (#22957)

  • if array >> if array is not None
    ... this should work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs workflow approval For PRs from new contributors, from which GitHub blocks workflows by default.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: QuadMesh get_cursor_data errors if no array is set
4 participants