-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
[BUG] Scatter plots silently plot wrong data when NaNs are present #3258
Comments
I can see how this is unexpected and that is really unfortunate. However, I am afraid that this is the expected behavior, because |
Yes, I've used that segment functionality and found it very convenient. But now that this bug/feature bit me really hard I think something needs to change. I had no lines in my figure so segment breaks weren't even on the radar in my case. Further, NaNs naturally arise in scientific computations and since they propagate correctly without errors (and plot invisibly as expected), many times people don't bother detecting and handling them. Having Plots silently shift other dimensions when NaNs are present is just too dangerous behavior for the main visualization tool in a computations-oriented language. So let me begin brainstorming how to resolve this:
|
I have to agree. The segment functionality is very handy, but having Plots shift parameter arrays without so much as a warning is extremely dangerous. I'm currently combing through my old code to see if this affected any of my plots, because I had no idea this "feature" existed until now. |
I think @niclasmattsson first suggestion:
sounds like a good solution. |
If, I'm not mistaken, then we would not be able to allow automatic cycling anymore, like in scatter(rand(6), color=[:red, :blue, :green], marker=[:square, :circle]) I'm not sure how widely these things are used and maybe it would be better to be a little bit more restrictive regarding the input in Plots and I am open to discuss this, but a change like this would be really breaking and could only happen in Plots 2.0 |
How about semiautomatic cycling then? :)
That keyword argument flag suggests a fourth idea for my brainstorm list: maybe interpreting NaNs as segment breaks must be enabled by specifically adding I understand that any breaking change has to wait for the next major release. In any case, thanks for listening and taking this seriously. |
I've just found this issue report, after writing a fix (I'll send the PR soon, after adding some tests). I've been bitten by this several times recently. |
Details
When you plot an XY scatter plot with additional dimensions of data in markers or colors, any NaNs in the XY data will shift the markers and colors and cause Plots to display incorrect data.
I hope this gets immediate attention because I think this is a super serious problem. I very nearly submitted a paper with completely messed up results because of this.
Demo (correct): note that the third circle is large and green.
Now change a coordinate for circle 2 to NaN and note what happens with circle 3.
Backends
This bug occurs on ( insert
x
below )Versions
Plots.jl version: 1.10.2
Backend version (
]st -m
):Output of
versioninfo()
:The text was updated successfully, but these errors were encountered: