Use Matplotlib.pyplot.rcparams With A Custom Font Which Is Not Installed
I'm trying to use a custom ttf font not installed in the system for text element in the matplotlib figure. with plt.style.context('mplparams.mplstyle'): plt.plot(np.sin(np.lins
Solution 1:
The font to be used has to be known to the Fontmanager, otherwise you cannot get it into the plot. In order to specify a font through rcParams this font must be found in a folder matplotlib would look for it. In case you don't want to install anything, you may copy the .ttf
file to the matplotlib font folder. In my case this is
python\Lib\site-packages\matplotlib\mpl-data\fonts
Then you need to clear the font.chache. Find out its path via print(matplotlib.get_cachedir())
and delete the fontList files. (Or make a backup first if you like).
Then run your script which has the rcParam specified
font.sans-serif : <name of font>
or use
plt.rcParams['font.sans-serif'] = "<name of font>"
Also see this question.
Post a Comment for "Use Matplotlib.pyplot.rcparams With A Custom Font Which Is Not Installed"