小编olb*_*en1的帖子

Matplotlib pyplot.title(string)返回错误

当我调用pyplot.title('some string')它时抛出异常,'str' object is not callable'.我从matplotlib在线文档中复制了以下内容:

mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)

# the histogram of the data
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)


plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title('Histogram of IQ')
plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
plt.axis([40, 160, 0, 0.03])
plt.grid(True)
plt.show()
Run Code Online (Sandbox Code Playgroud)

得到

TypeError                                 Traceback (most recent call last)
<ipython-input-158-40fe7a831b06> in <module>()
      8 plt.xlabel('Smarts')
      9 plt.ylabel('Probability')
---> 10 plt.title('Histogram of IQ')
     11 plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
     12 plt.axis([40, 160, 0, …
Run Code Online (Sandbox Code Playgroud)

python matplotlib ipython-notebook

19
推荐指数
5
解决办法
2万
查看次数

标签 统计

ipython-notebook ×1

matplotlib ×1

python ×1