-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Matplotlib "eats" points when zeros present on logscaled scatter plot #2872
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
Not happing here, also 1.3.1. |
If it helps, this is on OS X (10.9.2); matplotlib installed via pip. |
What backend are you using? I can not reproduce this on master (linux, pyqt) |
The backend is "MacOSX", Python 2.7.6. |
@mdehoon, @cimarronm, @efiring Can one of you take a look at this? I suspect this is a macosx backend bug. I do not have easy access to a mac for testing this. |
I can't reproduce this with macosx backend, master, python 2.7.3, numpy 1.7.0. |
Some more information: NumPy 1.8.0 WXAgg and TKAgg work correctly (the troublesome point is simply skipped), as does "Agg" and using savefig() to output a PDF file. |
I can reproduce it with the MacOS backend on 1.3.1. Works as expected using the QT backend. |
@jenshnielsen what is your numpy version? |
I cannot reproduce with MacOS backend on master, numpy 1.8.0 and python 3.3.4 |
Numpy 1.8.1rc1 and python2.7 |
OK it is not numpy. I also tried 1.8.1rc1 and python 2.7, and with mpl master I can't reproduce it. I hope this means that whatever it is, it is already fixed in master. |
I did some further testing: on my system this bug IS present in the v1.3.x branch (8863ac), and IS NOT present in master (93de06). |
Maybe fixed with #1886? |
Given that this is fixed in master, that a release from master is in the works, and that it is not clear whether there will be another 1.3 release, I am closing this. |
The bug is being caused by the argument "offsets" in the call to gc.draw_path_collection. This argument contains NaN's if the log(0) data point is included. If we can assume that gc.draw_path_collection and other functions always receive valid arguments (i.e., not containing NaN's), then we can consider this bug fixed. However, if we cannot make that assumption, then gc.draw_path_collection contains a bug. It's fairly easy to fix gc.draw_path_collection such that NaN's are avoided (should they occur in the input arguments), but it may affect the drawing speed performance, so I'd be happier if we can assume that there won't be NaN's in the input arguments to drawing functions. |
From Collection._prepare_points() I conclude that a NaN is the intended marker for a missing value in offsets. Now, the question is why this causes a problem in 1.3.1 but not in master. |
Two reasons:
|
… when using a logarithmic scale), draw_path_collection may get offsets containing NaN's. In that case, using CGContextTranslateCTM once with translation and once with -translation will not restore the original CTM. This bugfix adds a check for NaN/inf.
Some what recently there was a change in how clipping for log plots worked, that might be related. |
Fix for issue #2872. Skip NaN's in draw_path_collection.
The following script demonstrates the issue with Matplotlib 1.3.1:
The problem occurs when using a scatter plot with logscaled axes; if zeros are present in the data, a substantial fraction of the points are discarded. Obviously zeros can't be displayed on a log plot, but I would have expected those points (and only those points) to be silently dropped, or at worst an exception be raised.
The text was updated successfully, but these errors were encountered: