Fix pyplot savefig output dimensions#206
Conversation
1222c45 to
bdb02c8
Compare
Merging this PR will improve performance by ×2.4
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_png_export_line_pyplot |
73.9 ms | 30.6 ms | ×2.4 |
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-pyplot-savefig-scale (bdb02c8) with main (321da5a)
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. ↩
Greptile SummaryThis PR aligns pyplot PNG exports with Matplotlib's physical pixel dimensions. The main changes are:
Confidence Score: 5/5This looks safe to merge. No blocking issues found in the changed code.
What T-Rex did
Important Files Changed
Reviews (1): Last reviewed commit: "Fix pyplot savefig output dimensions" | Re-trigger Greptile |
What changed
xy.pyplotPNG exports at one physical pixel perfigsize * dpipixel.bbox_inches="tight"padding.dpisavefig paths.Why
The pyplot shim already builds each chart at
figsize * dpi, butstitch_png()passed the native renderer its separate 2x quality default and doubled composed canvases again. As a result, a Matplotlib-compatible 640x480 figure was exported as 1280x960, and point-sized artists were also rendered at the wrong effective DPI.This change applies a 1:1 physical-pixel contract only at the pyplot compatibility boundary. The native
Figure.to_png()API retains its explicit 2x default.Impact
In the scoped 88-example static-2D Matplotlib gallery comparison:
similarto the stricternearfidelity tier;The two remaining dimension mismatches are separate issues:
matshowaspect handling (640x480 versus 480x480) and a one-pixel centimeter conversion rounding difference.Validation
536 passed, 65 skipped— completetests/pyplotsuite58 passed— focused savefig/layout/reference testscargo build --releasepasses