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

Box plots with log-scaled whiskers #7388

Open
alexcjohnson opened this issue Mar 12, 2025 · 0 comments
Open

Box plots with log-scaled whiskers #7388

alexcjohnson opened this issue Mar 12, 2025 · 0 comments
Labels
feature something new

Comments

@alexcjohnson
Copy link
Collaborator

The standard formula we use for the length of box plot whiskers is 1.5 * IQR (interquartile range, ie the third quartile minus the first quartile). This is based on comparing your distribution to a normal distribution, where any data beyond those whiskers is considered an outlier. However, if you're displaying your data on a log scale (and sometimes even if you're not) a log-normal distribution is likely more appropriate, in which case the whisker locations should be calculated based on the IQR in log units. This brings both fences up, in particular preventing the lower fence from ever going negative ie an infinitely long whisker on a log scale.

I'd propose a new attribute for box traces, something like distribution: 'normal' | 'log-normal' | 'auto' where 'auto' uses 'log-normal' when displayed on a log axis, otherwise 'normal'. I'll be happy to submit a PR to add this functionality.

@alexcjohnson alexcjohnson added the feature something new label Mar 12, 2025
chriddyp added a commit that referenced this issue Mar 19, 2025
Implements a new distribution attribute for box plots with three options:
- normal: Standard 1.5 * IQR rule for whiskers
- log-normal: Calculates whiskers based on IQR in log units
- auto (default): Uses log-normal on log axes, normal otherwise

Prevents negative whiskers when using log scales, which would appear as
infinitely long whiskers due to log axis behavior.

Fixes #7388

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant