小编Mic*_*cha的帖子

matplotlib的xkcd()无效

好的,我知道这个问题已经被问过很多次了,但是我没有这个问题:

我尝试在matbulotlib上使用xkcd-styleUbuntu 16.04 LTS 64位上使用python 2.7.12 64位,我使用matplotlib.org/xkcd/examples中的示例代码(见下文),但我仍然得到这个!

我做了什么

  • 通过pip安装matplotlib(版本2.2.2)
  • 安装xkcdxkcd脚本字体(来自ipython/xkcd-font)
  • 安装Humor Sans字体(来自imkevinxu/xkcdgraphs)
  • 更新字体缓存数据库(fc-cache -fv)
  • 删除〜/ .cache/matplotlib(整个目录)
  • 重启电脑
  • 验证,字体在〜/ .cache/matplotlib/fontList.json中

我有什么线索可以让这个工作?我很感激任何暗示!

问候,米哈

我使用matplotlib.org/xkcd/examples中的示例代码:

from matplotlib import pyplot as plt
import numpy as np

plt.xkcd()

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
plt.xticks([])
plt.yticks([])
ax.set_ylim([-30, 10])

data = np.ones(100)
data[70:] -= np.arange(30)

plt.annotate(
    'THE DAY …
Run Code Online (Sandbox Code Playgroud)

python ubuntu 64-bit matplotlib

9
推荐指数
1
解决办法
632
查看次数

Python编码注释格式

最初,我学会了用这种方式在Python 2.7中指定源代码编码:

# -*- coding: utf-8 -*-
Run Code Online (Sandbox Code Playgroud)

现在我注意到,PEP263也允许这样:

# coding=utf-8
Run Code Online (Sandbox Code Playgroud)

这些之间有什么不同吗?编辑器兼容性,跨平台等怎么样?

那么Python 3呢?这个注释是否仍然需要python 3或者python 3中的任何代码默认为utf-8?

python encoding commenting python-2.7 python-3.x

4
推荐指数
1
解决办法
79
查看次数