Hello,
When viewing a 2D map with plt.pcolormesh(), the values corresponding to the current mouse positions are not printed in the navigation toolbar (unlike plt.imshow()).
Is it an oversight, a bug or an incompatibility?
If none of these, could you please add this feature in the future ?
Thanks,
Patrick
pcolormesh cursor data turned out to be really slow for large meshes #21917, so it is now disabled by default. To get this capability you can turn on the mouseover property of the returned artist.
Thank you very much @greglucas,
Unfortunately This information cannot be found easily (on my opinion).
Maybe revisit the default choice (mouseover=True by default ?) considering that small basic applications are more common that large calculations ?
Regards,
Patrick
Unfortunately This information cannot be found easily (on my opinion).
I agree, it is not very well advertised or documented. PRs adding an example/documentation about this would be welcome.
Maybe revisit the default choice (mouseover=True by default ?)
I thought there was some discussion around whether to set a different default for different size meshes, but I can't find it from a quick search now. I can certainly see an argument that if mesh.size() < N where N ~100 (I'm not sure on the actual size where performance degrades) we could enable it by default. But, that may also cause some confusion when someone is making various mesh sizes that straddle that boundary and gets different interactions.
considering that small basic applications are more common that large calculations ?
I don't think that is particularly true. N=100 would be a pretty modest pcolormesh in my usage. I pretty strongly feel that people should not have to actively turn off Matplotlib defaults to stop their machines from locking up when doing something that others works efficiently. Note mouseover is an accepted kwarg to pcolormesh, and is documented at https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pcolormesh.html, so you need only do mesh = plt.pcolormesh(..., mouseover=True).
We could consider setting the default to None and allow mouseover to work if the mesh is rectilinear. I think for rectilinear meshes getting the cell values can be very fast even for huge data sets (two linear 1-D interpolations is really fast compared to arbitrary 2-D interpolation.). That would require some piping to be added to QuadMesh, but perhaps storing the rectilinearity is useful in other contexts. (note by rectinlinear I mean that x and y are Nx1, Mx1, not trying to figure out if the MxN matrices are rectilinear).
Additional note: When deactivated, the mouse over could display a hint like "Set pcolormesh(..., mouseover=True) to show coordinates" - if there is enough space. Shorter messages welcome.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
greglucas commented on Nov 9, 2022
pcolormesh cursor data turned out to be really slow for large meshes #21917, so it is now disabled by default. To get this capability you can turn on the mouseover property of the returned artist.
patquem commented on Nov 9, 2022
Thank you very much @greglucas,
Unfortunately This information cannot be found easily (on my opinion).
Maybe revisit the default choice (mouseover=True by default ?) considering that small basic applications are more common that large calculations ?
Regards,
Patrick
greglucas commented on Nov 9, 2022
I agree, it is not very well advertised or documented. PRs adding an example/documentation about this would be welcome.
I thought there was some discussion around whether to set a different default for different size meshes, but I can't find it from a quick search now. I can certainly see an argument that if mesh.size() < N where N ~100 (I'm not sure on the actual size where performance degrades) we could enable it by default. But, that may also cause some confusion when someone is making various mesh sizes that straddle that boundary and gets different interactions.
jklymak commented on Nov 9, 2022
I don't think that is particularly true. N=100 would be a pretty modest pcolormesh in my usage. I pretty strongly feel that people should not have to actively turn off Matplotlib defaults to stop their machines from locking up when doing something that others works efficiently. Note mouseover is an accepted kwarg to pcolormesh, and is documented at https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pcolormesh.html, so you need only do mesh = plt.pcolormesh(..., mouseover=True).
We could consider setting the default to None and allow mouseover to work if the mesh is rectilinear. I think for rectilinear meshes getting the cell values can be very fast even for huge data sets (two linear 1-D interpolations is really fast compared to arbitrary 2-D interpolation.). That would require some piping to be added to QuadMesh, but perhaps storing the rectilinearity is useful in other contexts. (note by rectinlinear I mean that x and y are Nx1, Mx1, not trying to figure out if the MxN matrices are rectilinear).
jklymak commented on Nov 9, 2022
Crossref #22693
timhoffm commented on Nov 9, 2022
Additional note: When deactivated, the mouse over could display a hint like "Set pcolormesh(..., mouseover=True) to show coordinates" - if there is enough space. Shorter messages welcome.
github-actions commented on Jan 12, 2026
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!