我想画个图:
from matplotlib import *
import sys
from pylab import *
f = figure ( figsize =(7,7) )
但是当我尝试执行它时,我得到了这个错误:
File "mratio.py", line 24, in <module>
f = figure( figsize=(7,7) )
TypeError: 'module' object is not callable
我以前运行过类似的脚本,我想我已经导入了所有相关的模块。
6条答案
按热度按时间tuwxkamq1#
figure
是matplotlib
提供的一个模块。您可以在Matplotlib documentation中了解更多信息
我认为您需要的是
matplotlib.figure.Figure
(类,而不是模块)这里有记录
或
或
或者使
pylab
工作而不与matplotlib
冲突:cvxl0en22#
您需要执行以下操作:
这里,
参考此处。
所以你得这样称呼它:
yuvru6vn3#
要防止将来出现有关matplotlib.pyplot的错误,请尝试执行以下操作:导入matplotlib.pyplot作为plt
如果您使用Jupyter笔记本电脑并用途:%matplotlib内联,请确保“%matplotlib内联跟随导入matplotlib.pyplot作为plt
Karthikr的答案是有效的,但可能无法消除与pyplot模块相关的其他代码行中的错误。
快乐编码!!
j2qf4p5b4#
代替
使用
5rgfhyps5#
对于Jupyter笔记本,我通过导入matplotlib.pyplot来解决这个问题。
现在可以使用
f = plt.figure()
绘制图。wqnecbli6#
错误库:
导入matplotlib作为plt
平面图(图尺寸=(7,7))
TypeError:"module"对象不可调用
但是
正确库:
导入matplotlib.pyplot作为plt
平面图(图尺寸=(7,7))
上面的代码为我工作相同的错误.