When I try and run, for example:
mpl.rcParams['font.family'] = 'serif'
plt.rcParams['figure.figsize'] = [15,7]
plt.plot(data['flow-time'], data['staticpressurerecovery'])
plt.xlabel('Time [s]')
plt.ylabel('Static Pressure Recovery [-]')
plt.title('McD13_4S3 Plenum: Performance Coefficient ')
plt.ylim((0.33, 0.4))
plt.grid()
plt.show()
in a Jupyter notebook, I get the following error message:
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\font_manager.py:1331: UserWarning: findfont: Font family ['serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
Things I've Tried:
Deleting the
fontList.cache,fontList.json, andfontList.py3.cacheUncommenting the font family related sections of the
matplotlibrcfileUninstalled and reinstalled
matplotlibusingpip uninstall matplotlibandpip install matplotlib
Nothing has solved the issue. The only possible way for me to get different fonts now is to use LaTeX as the backend, but that's slow and unnecessary.
Any ideas what I can try next?
Edit: I'm using Windows 10, so not using apt-get for me. That seems to be a common fix for these problems, but I can't do it. It appears those solutions just add Microsoft fonts to the Linux font manager, so it's probably not even relevant since I'm already on a Microsoft machine.
Minimum working Example:
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
mpl.rcParams['font.family'] = 'serif'
mpl.rcParams['font.serif'] = 'Computer Modern'
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2*np.pi*t)
plt.plot(t, s)
plt.show()
In fontList.json, Computer Modern is listed as an available font.