Skip to content
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

violin: honor bandwidth attribute even if values in a trace are identical #3626

Merged
merged 5 commits into from
Mar 19, 2019

Conversation

antoinerg
Copy link
Contributor

@antoinerg antoinerg commented Mar 12, 2019

Following botched PR #3625, this PR closes #3622 by honoring trace.bandwidth even if all the values are identical.

When no bandwidth is specified and all values are identical, it draws the violin as a line. Therefore, this PR also closes #2779!

@antoinerg
Copy link
Contributor Author

antoinerg commented Mar 12, 2019

At the moment, the default bandwidth for a violin with zero standard deviation (ie. all values are identical) is 1. Therefore, you will get a significant violin area as shown in this comment which is not what other libraries do (like Seaborn for example). For people who don't know the details of violin plot (like me yesterday), this may look weird/wrong.

@alexcjohnson do you think we should greatly reduce the bandwidth when all values are identical so the violin collapses?

@alexcjohnson
Copy link
Collaborator

Right, I think the default behavior with all identical values should be zero width, as you had in #3625. But if someone provides an explicit bandwidth, we should honor that as you do here.

@antoinerg
Copy link
Contributor Author

Right, I think the default behavior with all identical values should be zero width, as you had in #3625. But if someone provides an explicit bandwidth, we should honor that as you do here.

With commit 5acb518 we have a mock showcasing both situations (identical values with and without explicit bandwidth). I had to explicitly set the bandwidth to 1 on an existing mock to preserve baselines intact.

@@ -86,6 +86,9 @@
}
],
"layout": {
"template": {
"data": {"violin": [{"bandwidth": 1}]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of template 🏆

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I think I would prefer updating the baselines instead of tweaking the JSON mocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 4698df0

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big deal, but to me the original baselines are a lot easier to look at and understand what's going on. But of course either way it'll serve the function of catching unintended changes.

@alexcjohnson alexcjohnson added this to the v1.46.0 milestone Mar 12, 2019
@alexcjohnson
Copy link
Collaborator

💃
This seems like more than a bugfix, so merge if you're ready for 1.46 features.

@etpinard
Copy link
Contributor

@antoinerg looks like this PR resolves #2779 as well, correct?

@antoinerg
Copy link
Contributor Author

@antoinerg looks like this PR resolves #2779 as well, correct?

Yes it does! I updated my first comment to reflect that. Nice catch 👀

@etpinard
Copy link
Contributor

good to merge 💃

@antoinerg antoinerg merged commit ccfcd7d into master Mar 19, 2019
@antoinerg antoinerg deleted the pr-violin-3622 branch March 19, 2019 20:23
@dellshape
Copy link

dellshape commented Jan 30, 2020

Hi, a quick update, passed by here because I got the same problem.
But turns out now you can solve this by setting spanmode to "hard", therefore the "span goes from the sample's minimum to its maximum value."

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