-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: invalid value encountered with 'ortho' projection mode #22624
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
Comments
The warning occurs the first time x21 and y21 both are 0 (so it is a divide by zero error). A simple way fix it is to change the code to something like:
although the preferred syntax may differ. |
thanks @oscargus fror your reply
Whatever, I think one of this bugfix should be push in the next release. |
That is indeed a better solution. I can create a PR. Thanks!
|
Seems like one should use |
The warning is triggered when trying to get xyz coordinates for the mouse cursor and one of the axes is exactly orthogonal to the screen, but I wonder whether printing xyz coordinates in the toolbar even makes sense at all? Basically, we pick an arbitrary screen-z-depth for the cursor (based on the distance to the edges -- which is where the warning comes from) and print the corresponding xyz value, but if one e.g. carefully looks at the displayed xyz values while slowly moving the mouse across a (default, non-ortho) 3d axes, one will see that the value suddenly jumps when the mouse goes from "closer to one axis" to "closer to another axis". |
Displaying the (estimated) 3D pointer coordinates has been a feature in
mplot3d for over 10 years. The code that is used to compute this estimate
has been reused in other projects as well, and when this feature has broken
for other reasons, users have noticed and complained. I see no reason to
get rid of it entirely.
Now, if a better algorithm for computing the estimated coordinates can be
devised, all the better!
…On Thu, Mar 10, 2022 at 6:17 AM Antony Lee ***@***.***> wrote:
The warning is triggered when trying to get xyz coordinates for the mouse
cursor and one of the axes is exactly orthogonal to the screen, but I
wonder whether printing xyz coordinates in the toolbar even makes sense at
all? Basically, we pick an arbitrary screen-z-depth for the cursor (based
on the distance to the edges -- which is where the warning comes from) and
print the corresponding xyz value, but if one e.g. carefully looks at the
displayed xyz values while slowly moving the mouse across a (default,
non-ortho) 3d axes, one will see that the value suddenly jumps when the
mouse goes from "closer to one axis" to "closertto another axis".
In other words, I would suggest to just stop displaying mouse cursor xyz
values here.
—
Reply to this email directly, view it on GitHub
<#22624 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACHF6HGWOEACZLOBBB4EBLU7HK4TANCNFSM5QG3L5RA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I am not convinced the values make sense at all. For example, these are the xyz values printed when dragging the mouse across window (default 3d view) horizontally, along the middle y position: from pylab import *
from matplotlib.backend_bases import LocationEvent
rcdefaults(); rcParams["axes.unicode_minus"] = False # use ascii minus
fig = figure()
ax = fig.add_subplot(projection="3d")
fig.canvas.draw()
xyzs = []
screen_ry = .5
# drag mouse across window horizontally, along the middle y position
for screen_rx in np.linspace(0, 1, 1001):
screen_xy = fig.transFigure.transform((screen_rx, screen_ry))
pseudo_xy = ax.transData.inverted().transform(screen_xy)
ev = LocationEvent("", fig.canvas, *screen_xy)
ev.xdata, ev.ydata = pseudo_xy
if any([axis.pane.contains(ev)[0] for axis in ax._axis_map.values()]):
s = ax.format_coord(*pseudo_xy) # formatted string
xyzs.append([float(part.split("=")[1]) for part in s.split(",")]) # displayed xyz
else: # out of Axes
xyzs.append((np.nan, np.nan, np.nan))
xyzs = array(xyzs)
close(fig)
plot(xyzs[:, 0], label="x")
plot(xyzs[:, 1], label="y")
plot(xyzs[:, 2], label="z")
legend()
show() The jumping is... not nice. |
Actually, I have quickly skimmed through the issue list and didn't find anything related, but perhaps you have refs e.g. on the mailing list? |
Ok, so I am also having difficulty finding what I was thinking of, but, here are some issues where people expressed interest in having access to 3D coordinate information: #16156 This isn't a comprehensive listing of such interest, and it shows that users find the information that is displayed by |
I don't disagree with making it better behaved. However, the value currently displayed is simply worse than useless, it is misleading (it does not correspond to the dot they are pointing to). |
Bug summary
Hello,
Passing the mouse on the figure when plot has been generated with 'ortho' projection 3d mode and specific azimuthal and elevation angles returns the following message :
C:....\lib\site-packages\mpl_toolkits\mplot3d\proj3d.py:25: RuntimeWarning: invalid value encountered in double_scalars
u = (x01x21 + y01y21) / (x21¨¨2 + y21¨¨2)
Could you please investigate this ?
thanks,
Patrick
Code for reproduction
Actual outcome
C:....\lib\site-packages\mpl_toolkits\mplot3d\proj3d.py:25: RuntimeWarning: invalid value encountered in double_scalars
u = (x01x21 + y01y21) / (x212 + y212)
Expected outcome
No RuntimeWarning message
Additional information
No response
Operating system
Windows
Matplotlib Version
3.4.2
Matplotlib Backend
No response
Python version
3.7.7
Jupyter version
No response
Installation
pip
The text was updated successfully, but these errors were encountered: