-1

I'm trying to get Matplotlib's xkcd style to use the font designed for it, Humor Sans.

I'm getting Comic Sans instead, see pic enter image description here

Now, the point is about the correct font not getting recognised here, I have removed the cache as per here and as suggested in the same question. Basically what is suggested in this other question.

I have even "forced" Matplotlib to regenerate the font cache as

f = matplotlib.font_manager.FontManager()

and looks like the desired font is there:

f.findfont("Humor Sans")
'/Users/myname/Library/Fonts/Humor-Sans.ttf'

So I don't get why the plot still shows Comic Sans? It has been obtained with code

plt.xkcd()  
plt.plot([i for i in range(10)], np.sin([i for i in range(10)])) 
plt.title('A sine wave') 
plt.show()

I even tried changing backend as per this Q&A, to no avail.

Community
  • 1
  • 1
mar tin
  • 9,266
  • 23
  • 72
  • 97
  • I think clearing the fontcache means deleting the fontList in you matplotlib [cache directory](https://matplotlib.org/faq/troubleshooting_faq.html#matplotlib-configuration-and-cache-directory-locations). Have you done that? – ImportanceOfBeingErnest Apr 26 '17 at 23:17
  • @ImportanceOfBeingErnest I have, yes, checked where the cache dir is and run `rm ~/.matplotlib/fontList.cache` – mar tin Apr 27 '17 at 07:09

1 Answers1

0

The solution was to also clear the cached font_manager instance, as

rm ~/.matplotlib/fontList.py3k.cache
mar tin
  • 9,266
  • 23
  • 72
  • 97