Closed
Description
Bug report
Bug summary
When rcParams['font.family']
is set to 'sans-serif', matplotlib correctly fallback to 'DejaVu Sans' (a warning is displayed and the "DejaVu Sans" font is plotted). However when rcParams['font.family']
is directly set to 'DejaVu Sans', matplotlib seems to use another font without warning.
Code for reproduction
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['font.family'] = 'sans-serif'
fig, ax = plt.subplots(figsize=(1,1))
ax.set_title('no serif here as expected')
plt.show()
print(ax.title.get_font_properties().get_fontconfig_pattern())
mpl.rcParams['font.family'] = 'DejaVu Sans'
fig, ax = plt.subplots(figsize=(1,1))
ax.set_title('serif here as not expected')
plt.show()
print(ax.title.get_font_properties().get_fontconfig_pattern())
Actual outcome
Expected outcome
I would expect the font to be "DejaVu Sans" in both cases (i.e. without serif in both cases). It is possible that the warning message is, in fact, incorrect. But I can't find a way to display the font that is currently displayed on the graph.
Matplotlib version
- Operating system: Debian 10 (Buster, Testing)
- Matplotlib version: 2.2.2
- Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: 3.6.4
- Jupyter version (if applicable): 4.4.0 (similar problem outside jupyter)
Matplotlib was installed through conda (conda-forge channel).
Thank you.