Fix pyplot stem gallery rendering [mpl compatibility] - #241
Fix pyplot stem gallery rendering [mpl compatibility]#241sselvakumaran wants to merge 7 commits into
Conversation
Merging this PR will improve performance by 38.16%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_first_payload_errorbar_large |
770 ms | 557.3 ms | +38.16% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing agent/fix-matplotlib-stem-markers (6e22e1c) with main (9d5865a)
Footnotes
-
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. ↩
|
stem plot in matplotlib is rendered with a red line (y=0) and with padding around it (as opposed to directly rendering x=[0,~6.25] y=[0,~2.75] it renders a box more like x=[-0.1,~6.35] y=[-0.1,~2.85]), either the API defaults are not correct and maybe it should be updated to match (mainly the stem line + being able to show that line) or the API is rejecting the customization arguments. the diamonds are also solid not hollow in the second plot. they also seem to be relatively small (is this a problem with 2x scale?) |
|
Addressed the new stem-gallery feedback in The missing default red baseline/padding had a separate root cause from the general pyplot margin work: core autoranging treated every trace with Exact gallery evidenceThe columns compare the initial PR implementation ( I reran the exact adapted Matplotlib
Focused verification: This intentionally does not import PR #240's general 5% pyplot-margin change. The core currently applies its existing 3% padding here; the stem-specific bug was the incorrect zero pinning. |
|
Follow-up on the new CodSpeed red: I investigated it and reran the benchmark workflow once. This does not appear to be a code regression from this PR. Evidence:
The rerun reproduced the cross-environment classification, so changing unrelated selection code would be unjustified. Current rollup is 27 successful checks and only this 1 external CodSpeed analysis red; all required CI, Matplotlib 3.11 compatibility, docs, wheels, and the benchmark workflow itself are green. The remaining action is to acknowledge the environment-mismatched result in CodSpeed (or refresh the baseline on a comparable environment), not make a stem-code performance change. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |

Summary
0..1viewstemtracebasefmt, marker-only styling such asset_markerfacecolor("none"), and Matplotlib-sized default markersStemContainer.remove()remove all three exposed artistsRoot cause
The pyplot extent scanner did not recognize the native
stemfactory. It therefore classified a populated stem axes as dataless and materialized0..1domains, clipping nearly all geometry. The adapter also represented the marker line, stem lines, and baseline with one shared artist and omitted the baseline rule entirely.Matplotlib gallery reference and before/after
Official source: Matplotlib
stem_plot.pyThe panels below are the unmodified gallery calls. Each image shows Matplotlib 3.11, XY before this PR, and XY after this PR at the same normalized display size.
Default stem plot
Custom baseline and hollow diamond markers
Validation
pytest -q tests/pyplot— 540 passed, 65 skippedruff checkandruff format --check— passedgit diff --check— passed