I have tried to install xkcd fonts 'Humor Sans', but unfortunately, I am not able to use the fonts. Here, is what I did so far:
- iPad Pro
- installed carnets and juno (for Jupyter notebooks)
- Matplotlib version 3.1.1
- installed iFonts to install Humor Sans
- run xkcd examples, e.g.
%pylab inline
plt.xkcd()
plt.plot(sin(linspace(0,10)))
plt.title('Whoo Hoo!!!')
The plot, with the exception of the fonts is working as expected. The error message gives me, what I expected:
findfont: Font family ['xkcd', 'xkcd Script', 'Humor Sans', 'Comic Sans MS'] not found. Falling back to DejaVu Sans.
The font manager does not find any Humor* Sans although in the Settings -> General -> Fonts, I do find the fonts.
import matplotlib.font_manager
x = [f.name for f in matplotlib.font_manager.fontManager.ttflist if f.name.startswith('Humor')]
print(set(x))
the outcome is an empty result:
set()
Since, the folder structure is not clear using the iPad, i have copied the HumorSans.ttf file in a folder "Fonts", e.g.
import matplotlib.font_manager as fm
import matplotlib.pyplot as plot
import numpy as np
font_path = 'Fonts/Humor-Sans.ttf'
my_font = fm.FontProperties(fname=font_path)
plt.xkcd()
fig, ax = plt.subplot()
x = np.linspace(0,3)
y = np.sin(x)
ax.bar(x, y, color='green')
ax.set_xlabel(u'Some x label', fontproperties=my_font)
ax.set_ylabel(u'Some y label', fontproperties=my_font)
ax.set_title(u'Some fancy title', fontproperties=my_font)
for label in ax.get_xticklabels():
label.set_fontproperties(my_font)
This works as expected. The fonts is the Humor Sans fonts, where I have explicitly changed the fonts. For all other texts, e.g. yticklabels, the fonts is the standard fonts such that the problem is still there.
How can I correctly install, either directly or load in each notebook the fonts. The problem is that i don't have access to the folders, I need to work in, e.g. matplotlib.get_cachedir() /private/var/mobile/Containers/Data/Application/AAD3....5693/tmp/matplotlib-nu6taz9_
Any help?