Skip to content

Fix step histogram autoscaling [mpl compatibility]#252

Draft
sselvakumaran wants to merge 3 commits into
agent/gallery-hist-errorbar-compatfrom
agent/histogram-normalization-compat
Draft

Fix step histogram autoscaling [mpl compatibility]#252
sselvakumaran wants to merge 3 commits into
agent/gallery-hist-errorbar-compatfrom
agent/histogram-normalization-compat

Conversation

@sselvakumaran

Copy link
Copy Markdown
Contributor

Summary

  • teach the pyplot autoscaler that compact stairs(values, edges) entries contribute bin edges on x and histogram heights on y
  • include filled-area geometry and its baseline in the same autoscale/scale-transform path
  • add regressions for step and stepfilled histograms, density normalization, and probability weights

Root cause

Axes.hist(..., histtype="step") correctly computed the bin counts, density, and weights, but stored the result as the compact stairs(values, edges) mark. Pyplot's entry scanner did not understand that reversed argument order and classified stairs-only panels as dataless, pinning both axes to the empty (0, 1) range. This clipped the real [-4, 4] distributions in Matplotlib gallery statistics/histogram_normalization.py figures 7–8.

Validation

  • 550 passed, 65 skipped across tests/pyplot
  • Ruff check and format clean
  • exact Matplotlib 3.11 88-example gallery harness: 65 examples / 105 figures paired at the current union head, with figures 7–8 restored and no gallery-wide count regression

A Matplotlib / before / after comparison is attached in the PR comments.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 737d44d8-9b17-4a9a-9202-6a43fe4c429e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/histogram-normalization-compat

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

Exact gallery verification against Matplotlib 3.11:

Matplotlib 3.11 vs current union vs fixed histogram normalization

The middle column is the authoritative current-head union of #206, #240#248, and #211. The right column applies this PR on top of that union.

The histogram counts were already numerically correct; the compact stairs(values, edges) entry was omitted from pyplot autoscaling, so stairs-only panels were pinned to the empty (0, 1) view. The fix restores the real [-4, 4] bin domain. Regression tests also prove sum(density * bin_width) == 1 and probability weights sum to one.

The remaining inter-panel ylabel spacing visible in output 008 is independent grid-layout work, so I am keeping it out of this technical autoscale PR and treating it as a separate layout fix.

@codspeed-hq

codspeed-hq Bot commented Jul 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 102 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing agent/histogram-normalization-compat (a5d0c7e) with agent/gallery-hist-errorbar-compat (f1e0be4)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@sselvakumaran sselvakumaran changed the title Fix step histogram autoscaling Fix step histogram autoscaling [mpl compatibility] Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant