10
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

3 Answers 3

20

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)>
Sign up to request clarification or add additional context in comments.

2 Comments

thank you! one simple stupid mistake and I lost 3 hours.
So when it happens a problem like this, by using plt.xlim() without any arguments, you can easily reset the axis limits to their default values, without the need to restart the kernel as suggested in many other places!
0

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

Comments

-1

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.

1 Comment

Please don't add "thank you" as an answer. Instead, vote up the answers that you find helpful. - From Review

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.