Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ps: Fix anchoring of rotated usetex text #25784

Merged
merged 2 commits into from Aug 2, 2023

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Apr 28, 2023

PR Summary

In PostScript, usetex text is anchored to the bottom left for replacement by psfrag, while in Matplotlib, text is placed by the baseline usually. So PostScript subtracts the text depth from the y position, but for rotated text, this subtraction should also be in a rotated direction.

I added test images for all 4 formats (eps + defaults) which might be a bit overkill, but as this problem would only manifest when you looked at the result, it was the only way to check. And while I did add markers for checking the alignment, I really just compared .eps with .pdf or .png as those appeared to be correct already.

Fixes #9158

PR Checklist

Linked Issue

  • Added "closes #0000" in the PR description to link it to the original issue.

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • [n/a] Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • [n/a] New plotting related features are documented with examples.

Release Notes

  • [n/a] New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • [n/a] API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • [n/a] Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

@QuLogic
Copy link
Member Author

QuLogic commented Apr 28, 2023

Hmm, locally, I'm already seeing a failure of test_multi_font_type3[eps] and test_multi_font_type42[eps], so the failure here is probably a similar manifestation of that problem. I'm guessing Fedora has a newer version of Ghostscript or similar, which is causing the small differences.

@QuLogic
Copy link
Member Author

QuLogic commented May 31, 2023

Can't reproduce in Ubuntu 22.04 WSL; probably an update to Ghostscript or similar.

@jklymak jklymak requested a review from anntzer June 14, 2023 23:42
In PostScript, usetex text is anchored to the bottom left for
replacement by psfrag, while in Matplotlib, text is placed by the
baseline usually. So PostScript subtracts the text depth from the y
position, but for rotated text, this subtraction should also be in a
rotated direction.
@QuLogic
Copy link
Member Author

QuLogic commented Jun 15, 2023

Since we recently moved a CI to Ubuntu 22.04, I rebased this to test against it. As expected above, it does pass on that system. Looking at the result on 20.04, it's a bit unexpected as only the markers on the far right column are missing.

@QuLogic
Copy link
Member Author

QuLogic commented Jun 15, 2023

Since Fedora is on Ghostscript 9.56.1 or above, Ubuntu 20.04 is 9.50, and Ubuntu 22.04 is 9.55, I've set an increased tolerance for any version < 9.55. The Ubuntu releases between those don't seem to have available repos, so I don't want to spend too much time investigating further into it.

@ksunden ksunden merged commit 950d0db into matplotlib:main Aug 2, 2023
39 checks passed
@QuLogic QuLogic deleted the ps-usetex-anchor branch August 2, 2023 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Angled text not placed correctly with usetex in EPS
3 participants