Skip to content

Outlier slows down zooming in scattergl #6174

Open

Description

@mzechmeister

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>

Activity

  1. alexcjohnson commented on May 3, 2022

    @alexcjohnson
    Collaborator

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

    stash.tree = cluster(positions);

  2. mzechmeister commented on May 4, 2022

    @mzechmeister
    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.

  3. CallumNZ commented on Feb 21, 2023

    @CallumNZ
    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.

  4. self-assigned this
    on Jul 4, 2024
  5. removed their assignment
    on Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions