npkp
npkp

Reputation: 1241

'tuple' object is not callable error using matplotlib library?

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()

Why do I keep getting error 'tuple' object not callable online 7 ? please explain

Upvotes: 10

Views: 20208

Answers (3)

MH Zardary
MH Zardary

Reputation: 34

This was a strange error that took my time for an hour. Finally, I found out that in the previous cell I used plt.xlim with '=' sign, in the wrong cell I hadn't got an error but it shows itself in the next cell.

Upvotes: -1

Dushyen Tewani
Dushyen Tewani

Reputation: 1

Correct Code which I tried. plt.figure( figsize=(14, 14))

Restart the kernel and error will go. Even if you load the dataframe you will get the same error.

In case anyone gets following error:

TypeError Traceback (most recent call last) in ----> 1 plt.figure( figsize=(2, 5))

TypeError: 'tuple' object is not callable

Upvotes: 0

Idodo
Idodo

Reputation: 1428

It looks like you may have overwritten the plt.xlim function.

Did you perhaps run plt.xlim=(-1000, 10000)? (note the "=")

type plt.xlim and run it to check.

Output should be something like:

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

Upvotes: 20

Related Questions