-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Bad superscript positioning for some fonts #5542
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
Comments
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. |
@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 ( 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 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. |
Ah, yes. Of course, you're right about that.
I think we can definitely take the The workaround for @adrn on 1.5 might be to either use |
Thanks for the ideas @mdboom -- using |
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
The text was updated successfully, but these errors were encountered: