如何在matplotlib上获取XKCD字体

era*_*ran 5 python matplotlib

我已设法复制图表:

http://matplotlib.org/xkcd/examples/showcase/xkcd.html

但是我的字体看起来不像那样.如何将文本字体更改为酷xkcd字体?

Rob*_*obᵩ 6

引用输出>>> help(plot.xkcd):

For best results, the "Humor Sans" font should be installed: it is
not included with matplotlib.
Run Code Online (Sandbox Code Playgroud)

  • 十分感谢!1.下载字体Humor-Sans.ttf 2.将其放在/ usr/share/fonts/truetype/humor-sans 3.运行`sudo fc-cache -f -v`刷新字体缓存,现在可以正常工作. (4认同)
  • 并在安装后清除matplotlib字体缓存:Win7:`%userprofile%\。matplotlib` Ubuntu:`〜/ .cache / matplotlib` (2认同)