如何在matplotlib上获取XKCD字体

5

https://dev59.com/BoPba4cB1Zd3GeqPnx_j - Barranka
我完全复制了您提供的链接中的示例。我不得不升级我的 matplotlib 版本到 1.4.0。这个版本包括 xkcd。从示例中生成的图表采用 xkcd 风格,并且效果非常好。 - The Dude
它对我也有效。我问的是字体。:) 我仍然得到一个常规字体。 - eran
请复制粘贴您正在运行的程序和生成的图像。 - Robᵩ
可能是使用matplotlib获取xkcd图的重复问题。 - bastelflp
1个回答

7

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

For best results, the "Humor Sans" font should be installed: it is
not included with matplotlib.

5
好的,谢谢!
  1. 下载了字体文件Humor-Sans.ttf
  2. 将它放在/usr/share/fonts/truetype/humor-sans目录中
  3. 运行 sudo fc-cache -f -v 命令以刷新字体缓存 现在字体可以使用了。
- eran
2
安装完成后,请清除matplotlib字体缓存:Win7:%userprofile%\.matplotlib Ubuntu:~/.cache/matplotlib - bastelflp

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接