I read that you can write and import style sheets for matplotlib
to use. Is there a way to load a font from a custom path in such a file? I know how to load the font directly in my .py
file, but I want to know, can this be done externally? The idea would be to be able to use this style sheet for several projects.
Minimal example:
A style sheet my.mplstyle
:
font.sans-serif : path/to/font/MyFont.otf
The main file main.py
:
import matplotlib.pyplot as plt
plt.style.use("./my.mplstyle")
fig, ax = plt.subplots()
plt.show()
Running python main.py
raises a series of warnings of the form
findfont: Generic family 'sans-serif' not found because none of the following families were found: path/to/font/MyFont.otf