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

What to do with notched box traces with "inverted ends" ? #4088

Closed
destradafilm opened this issue Jul 29, 2019 · 10 comments · Fixed by #4388
Closed

What to do with notched box traces with "inverted ends" ? #4088

destradafilm opened this issue Jul 29, 2019 · 10 comments · Fixed by #4388
Assignees

Comments

@destradafilm
Copy link

destradafilm commented Jul 29, 2019

I'm implementing the boxplot notched option, but don't really know what it is exactly and how to explain it to users that choose that option. The plotly documentation doesn't explain how it's calculated

the only thing I found useful online when researching was this:
https://sites.google.com/site/davidsstatistics/home/notched-box-plots

The Notch - displays the a confidence interval around the median which is normally based on the median +/- 1.57 x IQR/sqrt of n. According to Graphical Methods for Data Analysis (Chambers, 1983) although not a formal test the, if two boxes' notches do not overlap there is ‘strong evidence’ (95% confidence) their medians differ.>

Also, there are inverted ends when I add notches. I'm not sure if this is a bug or expected behavior
Screen+Shot+2019-07-29+at+4 17 03+PM

@destradafilm destradafilm changed the title request - better documentation for boxplot notched possible bug - boxplot notched and request for better documentation Jul 29, 2019
@etpinard
Copy link
Contributor

Also, there are inverted ends when I add notches.

Thanks for reporting. Could you share the data/layout you used to help us debug?

@destradafilm
Copy link
Author

Here is a codepen with an example of the bug:
https://codepen.io/destrada/pen/WVONOK

@destradafilm
Copy link
Author

hi @etpinard . I'm wondering if this has been labeled as a bug and if the codepen I provided helps show what the bug is? Thanks!

@etpinard etpinard self-assigned this Nov 25, 2019
@etpinard
Copy link
Contributor

etpinard commented Nov 25, 2019

The problem here has to do with samples that have median confidence intervals that go beyond Q1 (and/or Q3) and beyond the lower (and/or upper) fence value.

After a quick search, I couldn't find any notched boxplot examples that show "inverted ends". I suspect that some libraries bound the confidence interval to the IQR. But from #2305 (the PR that added notched boxes), looks like the author (@krassowski ) was ok with those "inverted ends" as that PR added two mocks showing inverted ends:

If "inverted ends" are a thing, then the problem is in our autorange-finding routine which should consider the median confidence interval in its computations.

If "inverted ends" were added in by mistake, then we should simply bound the median confidence interval accordingly in the calc step.

@etpinard etpinard changed the title possible bug - boxplot notched and request for better documentation What to do with notched box traces with "inverted ends" ? Nov 25, 2019
@etpinard etpinard removed their assignment Nov 25, 2019
@alexcjohnson
Copy link
Contributor

FWIW At least matplotlib allows inverted notches too https://stackoverflow.com/questions/38794406/why-is-matplotlibs-notched-boxplot-folding-back-on-itself

I feel like I’ve seen this elsewhere as well - And to me it seems like the most honest way to display the notches. But I suppose an option to bound them to the IQR would be a reasonable feature to add.

@krassowski
Copy link
Contributor

On my part, the inverted notches were intended - they highlight an important property of the distribution and are generated by all major packages including matplotlib (above), ggplot etc. Another link to an explanation: https://stats.stackexchange.com/questions/151580/how-to-interpret-notched-box-plots/151584

@krassowski
Copy link
Contributor

Also, see matplotlib/matplotlib#3631 (comment).

@etpinard
Copy link
Contributor

etpinard commented Nov 26, 2019

Thanks @krassowski @alexcjohnson !!

I'll adjust the autorange computations accordingly.

@destradafilm
Copy link
Author

sorry I'm late to the conversation. @etpinard thanks for fixing the autorange.
And thanks @alexcjohnson @krassowski for clarifying that inverted notches aren't considered a bug :)

@etpinard
Copy link
Contributor

... and thank you @destradafilm for reporting this bug !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants