以下是一段 Python3 代码,因为第 9 行有双换行符,所以无法正常工作:
# -*- coding: utf-8 -*-
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.text(4, 400, '-> 1 Pig ~ 150 kg\n\n-> Butching => 80 to 100 kg meat')
plt.axis([0, 7, 0, 2000])
plt.plot([0,1,2,3,4,5], [0,400,800,1200,1600, 2000])
ax.set_ylim([0, 2000])
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plt.show()
但是,如果我删除plt.xkcd()
这一行,则即使有双重换行符,一切也会正常工作。
有人知道原因吗?
这是一个bug还是有任何解决方法?
我的设置: Windows 7 amd64, python 3.3, numpy 1.8, matplotlib 1.3.1