Skip to content

Fix common normalization for density histograms - #3982

Open
yushuosun wants to merge 1 commit into
mwaskom:masterfrom
yushuosun:fix/hist-density-common-norm
Open

Fix common normalization for density histograms#3982
yushuosun wants to merge 1 commit into
mwaskom:masterfrom
yushuosun:fix/hist-density-common-norm

Conversation

@yushuosun

@yushuosun yushuosun commented Aug 31, 2026

Copy link
Copy Markdown

Hist._eval currently asks NumPy to normalize each semantic group independently when stat="density". By the time seaborn applies its common_norm grouping, the original counts have already been lost.

This keeps raw histogram counts in _eval and moves density normalization into _normalize, alongside the other normalized statistics. As a result:

  • the combined area is 1 with the default common_norm=True;
  • each group has area 1 with common_norm=False;
  • list-valued common_norm normalizes within each requested subset.

The full _stats test suite passes (74 passed, 2 skipped), including three regression tests added here.

This revives the approach from #3911, which was withdrawn by its author while the issue remained open. Thanks @Mr-Neutr0n for the original diagnosis and test cases.

Closes #3633.

Copilot AI lite review requested due to automatic review settings August 31, 2026 13:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

so.Hist ignores common_norm=True for the "density" aggregate statistic

2 participants