-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Font family is not set on log-scaled tick labels #8017
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
I can reproduce this bug, and it isn't present on 1.5.3 |
This is likely something fishy with mathtext... |
Bisects to 6bfd8b1 |
This isn't just isolated to tick labels. It's anywhere you put in math expressions in a byte string. Add |
what do you mean by 'byte string'? |
In my case this can be solved with: from matplotlib import rc
rc('mathtext', default='regular') which will use your specified font for math text, such as the |
I think this has to do with the mathdefault shim for for preserving the classic style. Using just 2.0 defaults the |
Actually I think the shim is wrong and uncessary: def _mathdefault(s):
"""
For backward compatibility, in classic mode we display
sub/superscripted text in a mathdefault block. As of 2.0, the
math font already matches the default font, so we don't need to do
that anymore.
"""
if rcParams['_internal.classic_mode']:
return '\\mathdefault{%s}' % s
else:
return '{%s}' % s The assumption of that the math font equals the regular font is not true in general. |
As a workaround import matplotlib.ticker
matplotlib.ticker._mathdefault = lambda x: '\\mathdefault{%s}'%x |
Removing this shim and always using |
The shim was put in place because the thinking was changing the default fonts would eliminate the need. That's not the case, as that prevents other font changes from being reflected when mathtext is used.
The shim was put in place because the thinking was changing the default fonts would eliminate the need. That's not the case, as that prevents other font changes from being reflected when mathtext is used.
BUG: Remove mathtext default shim for ticker (Fixes #8017)
Closed by #8354 |
I've noticed the workaround suggested doesn't work for cases where tick labels like "2 x 103" appear. These are styled with dejavu sans and there doesn't seem to be anything I can do to change them. They don't seem to use the usual mathtext or even roman
|
@binaryfunt Can you open a new issue for that? |
Bug report
Bug summary
Setting the font family through
rcParams
doesn't impact tick labels if the axis is log-scaled. The size of the font can be changed, but not the family (e.g. using the serif font).Code for reproduction
Actual outcome
As seen in this screenshot, the linear-scaled y-axis on the left has a serif font while the log-scaled y-axis on the right still has the default sans-serif font. In both cases the font size is set appropriately to 16. It's just the font family that doesn't change. (Pardon the 'shadow' between the two images, that's my Mac, not matplotlib).
Expected outcome
The code should produce tick labels on log-scaled axes with the specified font family.
Matplotlib version
python3 -m pip install --upgrade matplotlib
The text was updated successfully, but these errors were encountered: