Skip to content

Inconsistent effect of a trailing space on horizontalalignment="right" depending on mathtext presence #9694

Open
@anntzer

Description

@anntzer

Bug report

Bug summary

A trailing space after a mathtext block (but outside of the mathtext) and a traling space after a normal text block affect horizontalialignment differently.

Code for reproduction

from pylab import *
rcdefaults()
gca().set_axis_off()
axvline(0, lw=1)
text(0, .95, "$1.0$ ", ha="right")
text(0, .9, "$1.0$", ha="right")
text(0, .85, "1.0 ", ha="right")
text(0, .8, "1.0", ha="right")
text(.1, .95, "$1.0$ |", ha="right")
text(.1, .9, "$1.0$|", ha="right")
text(.1, .85, "1.0 |", ha="right")
text(.1, .8, "1.0|", ha="right")
text(.2, .95, "mathtext + space")
text(.2, .9, "mathtext - space")
text(.2, .85, "text + space")
text(.2, .8, "text - space")
show()

Actual outcome

figure_1

It is reasonable to have slightly different sizes for a space after a "0" in mathtext and a "0" in normal text. As the 1.0 |s show, the difference, if any, is minor (i.e. the space has more or less the same size). However, the horizontal alignment of $1.0$ and 1.0 with ha="right" are clearly quite different, with the space added in the mathtext case much smaller.

Expected outcome

More consistent behavior?

Matplotlib version

  • Operating system: Arch
  • Matplotlib version: 2.1/master
  • Matplotlib backend (print(matplotlib.get_backend())): qt5agg
  • Python version: 3.6
  • Jupyter version (if applicable): N/A
  • Other libraries: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions