-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
Bug report
Bug summary
if MP.rcParams['text.usetex'] == True, System fonts are not found and even ttf in the mpl folder are not recognized.
Before the upgrade to mpl 2.0.0, I was used to setting usetex and was able to take fonts from my system library. This, however, failed after the mpl 2.0.0 upgrade.
I managed a temporary, limited workaround by
- turning "usetex" to False
- copyint a ttf conversion of the font to the matplotlib library folder
However, this is insufficient because I occasionally require LaTeX functionality and want a font to be consistent with my document.
This might be related to http://stackoverflow.com/questions/42097053/matplotlib-cannot-find-basic-fonts/42841531
Code for reproduction
# minimal example
# the goal is to have a plot with LaTeX text and a custom font (Iwona)
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
mpl.rcParams['text.usetex'] = True # DOES NOT WORK.
## THIS, however, would work:
# mpl.rcParams['text.usetex'] = False
# the font "Iwona" is located in the texlive libraries as OTF
# and was converted to TTF via fontforge to be put to /usr/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf
mpl.rcParams['font.family'] = 'Iwona' # DOES NOT WORK.
## THIS, however, would work:
# mpl.rc('font',**{ \
# 'family': 'sans-serif' \
# , 'sans-serif': 'Avant Garde' \
# })
# from http://matplotlib.org/users/usetex.html#usetex-tutorial
t = np.arange(0.0, 1.0 + 0.01, 0.01)
s = np.cos(4 * np.pi * t) + 2
plt.plot(t, s)
plt.xlabel(r'time (s)', fontweight = 'bold')
plt.ylabel(r'il voltage (mV) $\mu$')
plt.title(r"mathtext is Number "
r"$\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!"
, color='gray')
plt.subplots_adjust(top=0.9)
plt.show()Actual outcome
All plot texts are reset to "DejaVu Sans". Optionally, "Avant Garde" works. Neither system fonts (from texlive), nor manually added ttf fonts from the "{matplotlib}/mpl-data/fonts/ttf" folder work.
Expected outcome
Before, on version 1.5, I simply set "usetex" to True and set the font in rc parameters to for example "Iwona". All text elements in the plot were correctly adjusted.
Matplotlib version
matplotlib 2.0.0 (both via pip or pacman)
python 3.6
manjaro linux (arch-based)
texlive-most (unchanged with MPL upgrade)
Thanks a lot!
... for your help or advice for a workaround.