| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Currently, the ps backend positions eps images into an imaginary page (the smallest standard page size which can contain the figure size, which happens to be lettersized for the default figure size), setting the %%BoundingBox based on that positioning. But the eps file format doesn't actually record the full page size (that's not the intent of the eps format anyways), just the position of the drawing relative to an origin. GhostScript is then used to rasterize the eps images during testing; it implicitly assumes a default page size of "letter" (https://ghostscript.readthedocs.io/en/latest/Use.html#choosing-paper-size) which just happens to match the page size selected above. So things are OK... except if the test figure is nondefault and actually *bigger* than lettersized; in that case ghostscript will just crop out whatever is out of the lettersized paper. Note that such an image comparison test won't *fail*; it will just fail to compare anything that's outside of the lettersize paper. Instead, pass -dEPSCrop to GhostScript (https://ghostscript.readthedocs.io/en/latest/Use.html#depscrop) which readjusts the papersize to match the eps bounding box. Test e.g. with ```python import subprocess from matplotlib.figure import Figure for fs in [5, 10, 15, 20]: Figure(figsize=(fs, fs)).add_subplot().figure.savefig(f"test-{fs}.eps") subprocess.run([ "gs", "-dNOSAFER", "-dNOPAUSE", "-dEPSCrop", "-o", f"test-{fs}.png", "-sDEVICE=png16m", f"test-{fs}.eps"]) ``` (Noted while troubleshooting failed tests on mplcairo, which does not perform the centering -- but there were so few tests using eps that the difference in behavior was entirely hidden by the general mplcairo test tolerance, until some more tests were added in matplotlib 3.6.)
|
I think CI failed because the test conversion cache should be invalidated -- added a commit that drops the caches to check that. -- Edit: that fixed it indeed; we need to decide how to handle that cache problem. |
Sorry, something went wrong.
|
The 1- is there for bumping when necessary. |
Sorry, something went wrong.
|
Ah, thanks for letting me know. Fixed accordingly. |
Sorry, something went wrong.
…ipt with -dEPSCrop.
…018-on-v3.6.x Backport PR #24018 on branch v3.6.x (When comparing eps images, run ghostscript with -dEPSCrop.)
| Back | FazBrowse Home | New Git URL |
Currently, the ps backend positions eps images into an imaginary page (the smallest standard page size which can contain the figure size, which happens to be lettersized for the default figure size), setting the %%BoundingBox based on that positioning. But the eps file format doesn't actually record the full page size (that's not the intent of the eps format anyways), just the position of the drawing relative to an origin.
GhostScript is then used to rasterize the eps images during testing; it implicitly assumes a default page size of "letter" (https://ghostscript.readthedocs.io/en/latest/Use.html#choosing-paper-size) which just happens to match the page size selected above. So things are OK... except if the test figure is nondefault and actually bigger than lettersized; in that case ghostscript will just crop out whatever is out of the lettersized paper. Note that such an image comparison test won't fail; it will just fail to compare anything that's outside of the lettersize paper.
Instead, pass -dEPSCrop to GhostScript
(https://ghostscript.readthedocs.io/en/latest/Use.html#depscrop) which readjusts the papersize to match the eps bounding box.
Test e.g. with
(Noted while troubleshooting failed tests on mplcairo, which does not perform the centering -- but there were so few tests using eps that the difference in behavior was entirely hidden by the general mplcairo test tolerance, until some more tests were added in matplotlib 3.6.)
Not really a regression, but would still be nice to have this in 3.6.1 to make testing of mplcairo simpler (otherwise I'll just xfail some more tests in mplcairo...).
PR Summary
PR Checklist
Tests and Styling
Documentation