You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ENH]: Global setting to make /mathdefault the default math type #22937
I am trying to generate scientific journal compatible figures in Matplotlib. Most of the journals have specific font requirements (e.g. Times New Roman) and I find myself typing something like $\mathdefault{_x}$ instead of just ${_x}$ throughout the script, which reduces the readability of the scrpit.
Proposed solution
Is it possible to have a global setting like matplotlib.rcParams that can be set once for the entire figure?
It is possible to set a single font for the entire figure, but multiple rcParams have to be set (as far as I know—if that's not the case, hopefully somebody will correct me). As a temporary workaround to avoid having to type mathdefault over and over again, if it is specifically Times New Roman that is needed, consider using STIX, which is designed to blend with Times New Roman.
I believe that the solution linked on discourse (setting mathtext.fontset = "custom", mathtext.rm = ..., mathtext.sf = ... as desired) is effectively the correct one, and using STIX as suggested by @tfpf should work too. Closing, but feel free to ping for reopen if you think more should be done.
Activity
qzhang234 commentedon Apr 29, 2022
Someone also asked the same question on Discourse:
https://discourse.matplotlib.org/t/how-to-make-mathdefault-the-default/20120?u=qzhang234
tfpf commentedon Apr 30, 2022
It is possible to set a single font for the entire figure, but multiple
rcParamshave to be set (as far as I know—if that's not the case, hopefully somebody will correct me). As a temporary workaround to avoid having to typemathdefaultover and over again, if it is specifically Times New Roman that is needed, consider using STIX, which is designed to blend with Times New Roman.Any other font can be used as well.
(It may be necessary to delete the font cache if you are using a recently-installed font.)
anntzer commentedon Jan 21, 2023
I believe that the solution linked on discourse (setting mathtext.fontset = "custom", mathtext.rm = ..., mathtext.sf = ... as desired) is effectively the correct one, and using STIX as suggested by @tfpf should work too. Closing, but feel free to ping for reopen if you think more should be done.