【问题标题】:How to get XKCD font on matplotlib如何在 matplotlib 上获取 XKCD 字体
【发布时间】:2014-10-01 17:11:11
【问题描述】:

我已经成功地复制了以下图表:

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

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

【问题讨论】:

  • 我已经完全复制了您提供的链接中的示例。我不得不将我的matplotlib 版本升级到1.4.0。此版本包括xkcd。该示例产生的绘图采用xkcd 风格并且工作完美。
  • 它也适用于我。我问了字体。 :) 我仍然得到常规字体。
  • 请将您正在运行的精确程序和生成的图像复制粘贴到您的问题中。

标签: python matplotlib


【解决方案1】:

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

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

【讨论】:

  • 太好了,谢谢! 1. 下载字体 Humor-Sans.ttf 2. 将它放在 /usr/share/fonts/truetype/humor-sans 3. 运行sudo fc-cache -f -v 刷新字体缓存,现在它可以工作了。
  • 并在安装后清除matplotlib字体缓存:Win7:%userprofile%\.matplotlibUbuntu:~/.cache/matplotlib
猜你喜欢
  • 2017-01-29
  • 2013-11-08
  • 1970-01-01
  • 2014-10-30
  • 2021-12-15
  • 1970-01-01
  • 1970-01-01
  • 2014-06-07
  • 2013-09-20
相关资源
最近更新 更多