-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
2.1 - new problem with log ax.transData #9369
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
This issue is ultimately due to #8836. You can follow the arguments there as to why the change was made. As far as I am concerned I do not believe these changes should be reverted (but would be happy to hear why they should, taking into account the arguments linked above). A nan in one axis will propagate to the other axis because transData relies on matrix multiplication, and the semantics of IEEE floats are such that
times
(where To restore previous behavior use |
I see your point that this would a result of matrix multiplication. (Can it actually be used for log axis?) But if axes are separable, use of a matrix multiplication seems unnecessary overkill. Gives you two extra superfluous multiply-add with zero (one per axis). And can cause trouble, as we have seen. For this matrix multiplication a non-IEEE multiplication where 0 * nan = 0 would be preferable ... In my application I define an x-scale that does not really know anything about the y-scale - and should not have to. Hence the trouble. My scale only wants to convert x-coordinates, and not know anything about y coordinates ... A solution could be if transforms that are separable have methods transform_x and transform_y to only transform those coordinates w/o carrying about the other. Maybe it already exists? |
Though this would be even more overkill, the technically correct solution for separable axes might be to use a sparse matrix. Then you never multiply the nan with a zero and add it to anything. |
https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.get_xaxis_transform.html#matplotlib.axes.Axes.get_xaxis_transform is what you want. See also https://matplotlib.org/users/transforms_tutorial.html#blended-transformations. The linear part of the transform is done at C-level by the rendering code, so using anything but a C-style array to represent the array is going to be tricky at best. |
Yes, this does the trick. Thank you! import matplotlib.pylab as plt
f = plt.figure()
ax = f.add_subplot(111)
ax.set_yscale('log')
ax.get_xaxis_transform().transform([0,0]) Output
|
One point I have been struggling with is to get the transform from data to axes coordinates. I have been using |
No, everything is rooted onto the display (pixel) coordinates so you should just go through them. Well perhaps it would have been nice if {transProjection+transProjectionAffine} == transLimits, but that's probably quite low in the priority list of refactors (as you have noted yourself it's quite easy to break things when fiddling with this kind of internals :-)) |
Closed by #9375, but don't let the conversation stop because of that! |
Bug report
ax.transData returns np.nan for x value if invalid y value is supplied if log yscale
Code for reproduction
Actual outcome
Expected outcome
Outcome in mpl 2.0.2 was
There is no real reason both values be nan.
Matplotlib version
print(matplotlib.get_backend())
): TkAggThe text was updated successfully, but these errors were encountered: