Skip to content

setting font.family: serif does not change math font to serif. #8702

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

Closed
maxnoe opened this issue Jun 2, 2017 · 9 comments
Closed

setting font.family: serif does not change math font to serif. #8702

maxnoe opened this issue Jun 2, 2017 · 9 comments
Milestone

Comments

@maxnoe
Copy link
Contributor

maxnoe commented Jun 2, 2017

Bug report

Bug summary

Setting

font.family: serif

Does not effect math text like ax.set_xlabel('$E / \mathrm{GeV}$').

Code for reproduction

import matplotlib.pyplot as plt

plt.rcParams['font.family'] = 'serif'
plt.plot([1, 2, 3])
plt.xlabel('$E / \mathrm{GeV}$')
plt.ylabel('E / GeV')

Actual outcome

sans-serif font for the axis label using math

test

Expected outcome

Both axes labels using serif font

Matplotlib version

  • Operating System: Ubuntu 16.10
  • Matplotlib Version: 2.0.2
  • Python Version: 3.6
@geib7592
Copy link
Contributor

geib7592 commented Jun 8, 2017

Your mathtext.fontset is probably set to the default value dejavusans. Adding

plt.rcParams['mathtext.fontset'] = 'dejavuserif'

should give you what you want.

@maxnoe
Copy link
Contributor Author

maxnoe commented Jun 8, 2017

Wow, this is really unexpected. For me at least.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Jun 9, 2017
@tacaswell
Copy link
Member

TODO:

@dstansby
Copy link
Member

Fixed by #8853

@maxnoe
Copy link
Contributor Author

maxnoe commented Mar 27, 2018

I think this is something that should not be "fixed" by adding documentation, but, you know, actually be fixed.

@ImportanceOfBeingErnest
Copy link
Member

@maxnoe Not clear what you mean by "actually be fixed".

The font set used for normal text is necessarily different from the one for MathText. As an example, Comic Sans MS does not have an integral symbol, right? So it makes sense to set both types individually with the respective rcParams.

@maxnoe
Copy link
Contributor Author

maxnoe commented Mar 27, 2018

This is changed behaviour compared to previous versions. Math sans text is in itself something very rare and not well supported (E.g. there is no open type math sf font).

But one should have at least have the option to just set a family then for math fonts. E.g. mathtext.fontfamily: serif

@maxnoe
Copy link
Contributor Author

maxnoe commented Mar 27, 2018

Also, Deja Vu Serif isn't actually a math font. There is TeX Gyre DejaVu Math, is matplotlib using this?

All math fonts i know are serif fonts:

  • Latin Modern Math
  • Libertinus Math
  • Stix Math
  • XITS Math
  • TeX Gyre {Bonum, Pagella, Schola Termes} Math
  • Asana Math
  • Cambria Math¹
  • Lucida Math¹
  • Minion Math¹

¹ commercial or proprietary fonts

@ImportanceOfBeingErnest
Copy link
Member

The font tables for the DejaVu fonts can be found at https://dejavu-fonts.github.io/Samples.html

There are currently 5 supported math fontsets ('dejavusans' (default), 'dejavuserif', 'cm' (Computer Modern), 'stix', 'stixsans'). You are able to select any of those via the mathtext.fontset rcParam. Introducing yet another rcParam to automatically choose one of those seems a bit overkill. Plus it would become very intransparent which font is finally used in cases where mathtext.fontset and the newly proposed rcParam contradict each other.

In any case if you feel that the current documentation can be improved at any point, people will be happy to hear your suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants