Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Vertical positioning in mathtext fraction rendering could be improved #18389

Open
Labels
keepItems to be ignored by the “Stale” Github Actiontopic: text/mathtext
@anntzer

Description

@anntzer

Bug report

Bug summary

The positioning by mathtext of the numerator, denominator, and fraction bar are less than optimal.

Code for reproduction

frompylabimport*forusetex,yin [(False,.4), (True,.6)]:figtext(.1,y,r"$\frac{1}{1}+\frac{x}{x}=\frac{y}{y}+\frac{t}{t}$",usetex=usetex)figtext(.4,y,r"$\frac{1}{1}+\frac{x}{x}=\frac{y}{y}+\frac{t}{t}$",usetex=usetex,size=42)ax=axes([0,0,1,1])ax.axhline(.65,lw=1)ax.axhline(.56,lw=1)ax.axhline(.455,lw=1)ax.axhline(.355,lw=1)show()

Actual outcome

test

Expected outcome

I think the most commonly noticeable problem is that digits appearing in the denominator tend to bump into the fraction bar. I used to believe that that was due to a discretization problem (i.e. we need to draw the fraction bar over an integer number of pixels to avoid blurring, so if we were supposed to have e.g. 1.5 pixels above and 1.5 pixels below this could get rounded to 2 and 1), which would still be annoying but arguably a reasonable tradeoff against blurring; but actually, rendering at large sizes shows that this is not the case (at size 42 the spaces are still clearly unequal).

The other cases are a bit more artificial, but show other aspects of the problem:

  • TeX puts a large-ish space above thex in the denominator, likely to make denominators line up across fractions; the denominators are very "jagged" in the mathtext case. TeX also only slightly bumps the height of they numerator to keep numerators nearly aligned without bumping into the fraction bar, whereas mathtext just pullsy up by its full descender.
  • TeX arranges for the fraction bars to clearly align with the+ sign and the center of the=, whereas mathtext's fraction bar is too low -- even though there's a comment inmathtext.py explicitly stating "Shift so the fraction line sits in the middle of the equals sign".

Matplotlib version

  • Operating system: linux
  • Matplotlib version: HEAD
  • Matplotlib backend (print(matplotlib.get_backend())): qt5agg
  • Python version: 38
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Actiontopic: text/mathtext

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp