2014-10-01 64 views
4

XKCD字體我已經成功地複製圖中:如何獲得matplotlib

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

但是我的字體看起來並不像。如何將文本字體更改爲cool xkcd字體?

+0

http://stackoverflow.com/questions/25679403/matplotlib-text-wont-display-in-xkcd-font – Barranka 2014-10-01 17:26:55

+0

我已精確複製從示例您提供的鏈接。我不得不將我的'matplotlib'版本升級到'1.4.0'。這個版本包含'xkcd'。這個例子產生的情節是'xkcd'風格並且完美。 – 2014-10-01 17:55:15

+0

它也適用於我。我問到了FONT。 :)我仍然得到一個正規的字體。 – eran 2014-10-01 18:33:07

回答

6

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

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

太好了,謝謝! 1.下載字體Humor-Sans.ttf 2.將它放在/ usr/share/fonts/truetype/humor-sans 3.運行'sudo fc-cache -f -v'刷新字體緩存 現在它工作。 – eran 2014-10-02 16:26:53

+1

安裝完成後清除matplotlib字體緩存:Win7:'%userprofile%\。matplotlib' Ubuntu:'〜/ .cache/matplotlib' – bastelflp 2015-11-28 21:38:46