我想用matploblib创建ROC曲线的XKCD样式的图形。它基本上很好用,但我不明白为什么它不使用幽默感。它肯定安装在我的系统上:
$ fc-list | grep -i humor
/home/user/.local/share/fonts/Humor-Sans.ttf: Humor Sans:style=Regular
如何使matplotlib使用无幽默字体?在
我已经尝试添加fontname='Humor Sans'
:
import matplotlib.pyplot as plt
import numpy as np
with plt.xkcd():
xs = np.linspace(0, 1, 50)
plt.plot(xs, (1 / (-xs) + 50) / 50)
plt.plot(xs, xs)
plt.title('ROC Curve')
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.savefig('xkcd-roc-explanation.png')
可以通过以下方式强制重建字体缓存:
然后检查字体可用性
^{pr2}$Matplotlib有自己的缓存文件。在我的系统中,我可以通过执行
相关问题 更多 >
编程相关推荐