好的,我知道这个问题已经被问过很多次了,但是我没有这个问题:
我尝试在matbulotlib上使用xkcd-style在Ubuntu 16.04 LTS 64位上使用python 2.7.12 64位,我使用matplotlib.org/xkcd/examples中的示例代码(见下文),但我仍然得到这个!
我做了什么
我有什么线索可以让这个工作?我很感激任何暗示!
问候,米哈
我使用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 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 ×2
64-bit ×1
commenting ×1
encoding ×1
matplotlib ×1
python-2.7 ×1
python-3.x ×1
ubuntu ×1