Skip to content

Outlier slows down zooming in scattergl #6174

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

Open
mzechmeister opened this issue Apr 30, 2022 · 3 comments
Open

Outlier slows down zooming in scattergl #6174

mzechmeister opened this issue Apr 30, 2022 · 3 comments
Labels
bug something broken P3 backlog

Comments

@mzechmeister
Copy link

I have large data sets, which have a fat tail, i.e. looks like having an outlier.
I use scattergl aiming for fast zooming. As shown in https://plotly.com/javascript/webgl-vs-svg
or in the example below, one million points can be done. However, if one point is set as an outlier, then zooming becomes very
slow. I don't understand this, and spent quite some time to pin down the problem.

https://jsfiddle.net/fasmu943

<!DOCTYPE html>
<html>
<div id="plotly-div1"></div>
<div id="plotly-div2"></div>

<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
<script>
function gaussianRand() {
    var rand = 0
    for (var i=0; i < 3; ++i) {
        rand += Math.random()
    }
    return (rand / 3) - 0.5
}

function plot(y, divnum){
   trace1 = {
      type: "scattergl",
      y: y,
   }
   layout = {
      height: 250,
      margin: {l: 40, r: 10, b: 30, t: 10}
   }
   Plotly.plot('plotly-div'+divnum, {
      data: [trace1],
      layout: layout,
   })
}

Y = []
for (var i=0; i < 1000000; i++) {
    Y.push(gaussianRand())
}

plot(Y, 1)

Y[800000] = 100.   // adding an outlier slows down zoom

plot(Y, 2)

delete Y

</script>
</html>
@alexcjohnson
Copy link
Collaborator

Thanks for digging in to this @mzechmeister - I suspect this case is problematic for our clustering algorithm for hover

stash.tree = cluster(positions);

@mzechmeister
Copy link
Author

Thanks for looking into the issue and the hover hint.
When setting hovermode: false in layout, then the zoom speed feels similar both cases. That helps for now.

@CallumNZ
Copy link
Contributor

I'm running into a similar problem. Some examples from one data set:

Range: 04-Feb to 21-Feb
Points: 103066
Lag on zoom? YES

image

Range: 04-Feb to 21-Feb, removing points from the middle that were outliers/not showing the same wave pattern.
Points: 85165
Lag on zoom? YES

image

Range: 06-Feb to 21-Feb
Points: 91866
Lag on zoom? NO

image

Range: 01-Feb to 17-Feb
Points: 97920
Lag on zoom? NO

image

Range: 01-Feb to 18-Feb
Points: 103680
Lag on zoom? YES

image

Setting hover mode: false as a workaround works as mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

4 participants