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

Bad superscript positioning for some fonts · Issue #5542 · matplotlib/matplotlib · GitHub

Repository navigation

Bad superscript positioning for some fonts #5542

Closed

Description

I like to use Computer Modern as my default font. I noticed that, after updating to v1.5.0, the superscript positioning for tick labels in, e.g., log-log plots is off from what it was in 1.4.3. I've only noticed this difference for CMU Modern, not the default sans-serif fonts. Was this an intentional change? See plots below -- titles specify mpl version number (I moved my matplotlibrc file to make these plots).

v1.4.3, sans serif

v1.4.3, CMU serif

v1.5.0, sans serif

v1.5.0, CMU serif

Code: https://gist.github.com/adrn/aebd2641be6142dedbdf

Activity

  1. tacaswell commented on Nov 22, 2015

    Member

    This was not intentional and I believe it has been fixed on v1.5.x and master.

    attn @zblz @mdboom

  2. added this to the milestone on Nov 22, 2015
  3. mdboom commented on Nov 23, 2015

    Member

    The positioning of the sub/superscripts is based on the font in use, and we have hardcoded the values for the fonts that ship with matplotlib, but it's isn't possible to determine them for every font (or even every variation of Computer Modern). Unfortunately, CMU Modern and Computer Modern are not precisely the same font (same source material, different names and character mappings), so when you use CMU Modern matplotlib doesn't know how to position the sub/superscripts correctly. The change between 1.4.3 and 1.5.0 is incidental: whereas before we used the positioning for Computer Modern for everything and you got lucky and every other font had the wrong position, now the positioning is appropriate for DejaVu by default and you're getting unlucky.

    I'll have to think on how best to fix this.

  4. zblz commented on Nov 23, 2015

    Member

    @mdboom: DejaVu will only be introduced for 2.0 as default, I believe this comes from the change we made to CM subsuper position in #4873, which went into 1.5.0. It seems that the improved positioning for Bakoma CM makes it worse for CMU.

    I have looked at it a bit deeper and it seems that the default formatter for log-scales (LogFormatterMathtext) uses a \mathdefault call around the 10^{-2} strings. This might have been a good idea as long the subsuper position matched both the mathtext and regular fonts (i.e., bakoma and bitstream vera, respectively), but since we tailored the subsuper position to each mathtext fontset, using these positionings for regular text might be ugly (as here).

    I think that Bakoma CM and CMU differ here in the height of their superscripted numbers, which CMU rendering them quite larger. Note how the $10^5$ in the x-axis label, which is rendered in Bakoma CM because it is mathtext with mathtext font, looks better than the y-axis tick labels.

    An option we have to fix this is to force mathtext font in log-scale labels (i.e., remove mathdefault call). This will result in CM labels in plots with sans elsewhere in 1.5.1, but will not be a problem in 2.0 because the default will be DejaVu for both.

  5. mdboom commented on Nov 23, 2015

    Member

    @mdboom: DejaVu will only be introduced for 2.0 as default, I believe this comes from the change we made to CM subsuper position in #4873, which went into 1.5.0. It seems that the improved positioning for Bakoma CM makes it worse for CMU.

    Ah, yes. Of course, you're right about that.

    An option we have to fix this is to force mathtext font in log-scale labels (i.e., remove mathdefault call). This will result in CM labels in plots with sans elsewhere in 1.5.1, but will not be a problem in 2.0 because the default will be DejaVu for both.

    I think we can definitely take the \mathdefault out for 2.0, and that's a good long-term solution in the context of all the other changes in 2.0. For 1.5.1, I don't think so -- I think changing all the log scaling text to Computer Modern is too breaking of a change.

    The workaround for @adrn on 1.5 might be to either use text.usetext: True (if you have a working LaTeX install), or use the cmr10 font (the Computer Modern matplotlib ships) and set axes.unicode_minus to False.

  6. adrn commented on Nov 23, 2015

    ContributorAuthor

    Thanks for the ideas @mdboom -- using cmr10 works fine.

  7. modified the milestones: , on Nov 23, 2015
  8. added 6 commits that reference this issue on Nov 23, 2015
    505a41d
    0fcff24
    34cf792
    47cd5b5
    731c044
    48e5cd9
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