Skip to content

Violin Plot stops the whole of process in specific condition. #6490

Closed

Description

@L0Z1K

plotly version is 5.13.0. When I run this code, jupyter notebook stops and throw this error.

import plotly.express as px

fig = px.violin(x=[0, 0], y=[0.5006312999999999, 0.5006313])
fig.show()

image

I think there is some problem when inputs has 2 distinct types like float32 and float64. This is quite critical to person who are analyzing the data with violin plot.

I think just convert float64 to float32 in process. But I don't know how to revise the code so I just throw the issue in here.

Activity

  1. alexcjohnson commented on Feb 17, 2023

    @alexcjohnson
    Collaborator

    Thanks @L0Z1K - I moved this to the plotly.js repo, because the same happens in plain plotly.js https://codepen.io/alexcjohnson/pen/ExejRPQ the page locks up with your data:

    Plotly.newPlot("myDiv", {
       "data":[
          {
             x: [0,0], y: [0.5006312999999999, 0.5006313],
             type:"violin"
          }
       ]
    })
  2. L0Z1K commented on Feb 28, 2023

    @L0Z1K
    Author

    So is there any plan to fix? or should I contribute by code to handle this issue?

  3. alexcjohnson commented on Mar 2, 2023

    @alexcjohnson
    Collaborator

    @L0Z1K if you're able to track down the source of this and suggest a fix that would be most welcome!

    My hunch is it's this:

    for(var k = 0, t = span[0]; t < (span[1] + step / 2); k++, t += step) {

    and the step is so small that sometimes k++; t += step doesn't actually change t because step is on the edge of the floating-point precision of the data values. Maybe it can be fixed by changing to k++, t = span[0] + k * step? Also perhaps change the termination condition to k < n. That said if several t values are identical there may be rendering issues we need to address too.

    If that fixes it, we'd also need a test - here if indeed the issue is just in the calc step, testing something about cd[0].density

  4. gvwilson commented on Jul 4, 2024

    @gvwilson
    Contributor

    Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions