FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: Inconsistent rendering between backends when rendering Mathtext horizontal rule · Issue #23763 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: Inconsistent rendering between backends when rendering Mathtext horizontal rule #23763

Closed

Description

Bug summary

When the last item in a Mathtext Vlist is an Hrule, the AGG and SVG backends render the image differently. The difference is not obvious at small font sizes.

To see this happen, we have to dive into Mathtext internals. An easy way is to modify fractions to end with the horizontal rule.

Code for reproduction

import matplotlib.pyplot as plt
import matplotlib._mathtext as _mathtext

plt.rcdefaults()

def _genfrac(self, ldelim, rdelim, rule, style, num, den):
    state = self.get_state()
    thickness = state.get_current_underline_thickness()
    vlist = _mathtext.Vlist([num, _mathtext.Vbox(0, 2 * thickness), _mathtext.Hrule(state, thickness)])
    return [_mathtext.Hlist([vlist])]
_mathtext.Parser._genfrac = _genfrac


(fig, ax) = plt.subplots()
plt.text(.5, .3, r'$\dfrac{up}{down}$', size=100, ha='center', va='baseline')
plt.axhline(.3)
plt.savefig('Hrule_at_bottom.png')
plt.savefig('Hrule_at_bottom.svg')
plt.show()

Actual outcome


PNG output


SVG output

Expected outcome

Both images should be identical.

Additional information

Why does it matter if it's related to a private module in Matplotlib?

This is one of the things holding up #23616. Vlists ending with an Hrule are not being positioned correctly.

Operating system

Ubuntu 20.04 LTS Focal Fossa on WSL

Matplotlib Version

3.5.0.dev5855+gee2f68bdc9

Matplotlib Backend

WXAgg

Python version

Python 3.8.10

Jupyter version

6.0.3

Installation

git checkout

Activity

  1. github-actions commented on Dec 22, 2025

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  2. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on Jan 22, 2026
  3. removed
    status: inactiveMarked by the “Stale” Github Action
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on Jan 31, 2026
  4. anntzer commented on Jan 31, 2026

    Contributor

    Closed by #30059, I believe. Feel free to reopen if I missed something.

  5. tfpf commented on Feb 1, 2026

    ContributorAuthor

    Verified! I cannot visually discern any alignment differences in the two images now.

  6. anntzer commented on Feb 1, 2026

    Contributor

    @tfpf Do you know if this being fixed has any implications regarding your comment at #31046 (comment)?

    This extra +/- rule is odd compared to TeX, but it is explained in the original PR

    Vlists containing Hrules don't render vertical spaces correctly. The code for reproduction given in #23763 still works!

    (i.e. is the extra +/- still relevant?)

  7. tfpf commented on Feb 1, 2026

    ContributorAuthor

    My first thought was that it might, but I think I was wrong! I have added the details in that thread.

  8. modified the milestones: v3.12.0, v3.11.0 on Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL