无法使用matplotlib绘图

时间:2014-03-16 23:38:41

标签: python matplotlib

我编写了下面的代码,但是当我运行代码时出现错误:

TypeError: 'module' object is not callable 

我的代码是:

import numpy as np
import matplotlib as plt

n = 10

aa = [float(i) for i in range(1, n)]
a = np.squeeze(np.asarray(range(1, n)))
bb = -0.8*np.exp(-a/1.4) + 1.4*np.exp(-a/2.0) + 0.4*np.exp(-a/3.0)
b = np.squeeze(np.asarray(bb))

plt.figure()
plt.scatter(a, b)# I used different combinations of a, aa, bb and b. None of them worked.
plt.show()

1 个答案:

答案 0 :(得分:2)

您需要导入行:

import matplotlib.pyplot as plt