【问题标题】:'tuple' object is not callable error using matplotlib library?使用 matplotlib 库的“元组”对象不是可调用错误?
【发布时间】:2020-06-28 16:41:26
【问题描述】:
1  def auto_correlate(x):
2     cor = np.correlate(x,x,mode="full")
3     return cor[N-1:]

4  c = np.zeros(N)
5  c = auto_correlate(x-ave)/N
6  plt.plot(c)
7  plt.xlim(-1000, 10000)
8  plt.xlabel(r'$i$',fontsize=16)
9  plt.ylabel(r'$\varphi(i)$',fontsize=16)
10 print('\sigma^2 = ', std**2)
11 plt.show()

为什么我不断收到错误 'tuple' object not callable online 7 ?请解释

【问题讨论】:

    标签: python-3.x


    【解决方案1】:

    看起来您可能已经覆盖了 plt.xlim 函数。

    您是否运行过plt.xlim=(-1000, 10000)? (注意“=”)

    键入plt.xlim 并运行它来检查。

    输出应该是这样的:

    <function matplotlib.pyplot.xlim(*args, **kwargs)>
    

    【讨论】:

    • 谢谢!一个简单的愚蠢错误,我损失了 3 个小时。
    【解决方案2】:

    我尝试过的正确代码。 plt.figure(figsize=(14, 14))

    重新启动内核,错误就会消失。 即使你加载数据框,你也会得到同样的错误。

    如果有人遇到以下错误:

    TypeError Traceback(最近一次调用最后一次) 在 ----> 1 plt.figure( figsize=(2, 5))

    TypeError: 'tuple' 对象不可调用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 2018-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-29
      相关资源
      最近更新 更多