Skip to content

Fix histogram and errorbar gallery compatibility [mpl compatibility]#247

Draft
sselvakumaran wants to merge 12 commits into
mainfrom
agent/gallery-hist-errorbar-compat
Draft

Fix histogram and errorbar gallery compatibility [mpl compatibility]#247
sselvakumaran wants to merge 12 commits into
mainfrom
agent/gallery-hist-errorbar-compat

Conversation

@sselvakumaran

Copy link
Copy Markdown
Contributor

What changed

  • support histogram facecolor, fill, and scalar/per-dataset linewidth
  • preserve Matplotlib's step / stepfilled fill override semantics
  • normalize scalar histogram input as one dataset
  • forward marker, markersize, linestyle, and dashes to the errorbar data line only
  • render directional endpoint markers for lolims, uplims, xlolims, and xuplims

Why

These gaps prevented two official Matplotlib 3.11 statistics examples from rendering at all. A script-exit-only pass initially exposed a second bug: one-sided error limits were still ordinary capped bars. This PR includes the visual geometry fix as well.

Official references:

Before, Matplotlib references, and after

Gallery impact

  • statistics/errorbar_limits.py: newly complete, 1/1 output
  • statistics/histogram_normalization.py: newly complete, 9/9 outputs
  • histogram_histtypes.py advances to the independent rwidth blocker
  • histogram_multihist.py renders its first three captures, then reaches the independent hatch blocker

This PR does not touch the global margin/tick-spacing work in #240.

Validation

  • 544 passed, 65 skipped across the full pyplot suite
  • focused histogram/errorbar geometry and forwarding tests
  • Ruff and git diff --check
  • exact official gallery rerenders visually compared with Matplotlib 3.11

@codspeed-hq

codspeed-hq Bot commented Jul 24, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 23.18%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 2 regressed benchmarks
✅ 101 untouched benchmarks
⏩ 1 skipped benchmark1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
test_select_lasso_message_1m 89.3 ms 127.3 ms -29.87%
test_pyramid_compose 9.3 ms 11 ms -15.84%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing agent/gallery-hist-errorbar-compat (fe6ce2b) with main (9b08085)2

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.

  2. No successful run was found on main (bf903bc) during the generation of this report, so 9b08085 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@sselvakumaran

Copy link
Copy Markdown
Contributor Author

first plot w/ error bar upper and lower limits - the CI errorbars (one vertical and two horizontals, like a capital I shape) should not be visible, just the arrows and the direct lines coming from the point should be visible. you can see this in the image provided. all five lines have this problem, but look at the blue line - the matplotlib one just has crosses with no horizontal bars besides the ones coming out of the point on the line, but the xy one also includes two more horizontals (the CI errorbars).

also, some of the arrows do not seem correct - for the purple points the second point has an arrow going left in mol, but the xy version has the arrow’s shaft goes left but the arrowhead points right (both should point left). up and down seems fine.

also minor nitpick but the lines seem slightly too long and not thick enough (is this a problem with 2x scale?)

in the second plot (bar plot w/ orange diamonds), the diamonds do not seem large enough (is this a problem with 2x scale?)

@sselvakumaran sselvakumaran changed the title Fix Matplotlib histogram and errorbar gallery compatibility Fix histogram and errorbar gallery compatibility [mpl compatibility] Jul 24, 2026

sselvakumaran commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review points in e2fb700 and c000c4c:

  • pyplot now uses Matplotlib's default errorbar.capsize = 0, so the extra CI-style cap strokes are gone
  • default errorbar width now comes from lines.linewidth (1.5 pt), and limit arrows use the normal 6 pt marker size
  • left/right triangle transforms were corrected in both WebGL and native PNG rendering
  • Matplotlib's d/D marker paths extend by sqrt(2) relative to markersize; XY had constrained them to the nominal box. PNG, SVG, and WebGL now use the Matplotlib geometry, which fixes the small orange diamonds

I reran the exact Matplotlib 3.11 gallery script. In the histogram panel, the visible diamond height at normalized 640x480 is now 6 px in both renders. The marker being half-clipped at y=0 is expected here: Matplotlib does the same because the histogram baseline is sticky. The 2x export scale was not the cause.

Before / Matplotlib 3.11 / after

The left column is the state reviewed above; the center is the exact Matplotlib 3.11 output; the right is a fresh render from c000c4c.

Reviewed state, Matplotlib 3.11 reference, and current PR after

Copy link
Copy Markdown
Contributor Author

I rechecked the current-head CodSpeed red separately from the visual review. It is not caused by this PR:

  • CodSpeed explicitly flags different runtime environments.
  • The only reported regression is the same unrelated test_select_lasso_message_1m outlier seen on other gallery PRs (93.3 ms → 124.4 ms).
  • The benchmark and its complete timed Python/Rust path are byte-identical to main: benchmarks/test_codspeed_selection.py, python/xy/channel.py, python/xy/_figure.py, python/xy/interaction.py, python/xy/kernels.py, and src/kernels.rs have no diff.
  • Fix histogram and errorbar gallery compatibility [mpl compatibility] #247 changes histogram/errorbar/marker translation and rendering; none of those files are invoked by the lasso benchmark's timed channel.handle_message call.
  • 101 other CodSpeed rows are unchanged and the full benchmark workflow passed.

There is therefore no causal performance fix to make in #247. The four human visual findings are covered by e2fb700/c000c4c and the exact Matplotlib 3.11 rerender evidence above.

@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: d7d40125-cfe0-44c3-8ba0-764bba070c01

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/gallery-hist-errorbar-compat

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

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