Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python-3.x

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

like image 775
npkp Avatar asked Dec 22 '17 19:12

npkp


People also ask

How do I fix tuple object is not callable in Python?

The Python "TypeError: 'tuple' object is not callable" occurs when we try to call a tuple as if it were a function. To solve the error, make sure to use square brackets when accessing a tuple at a specific index, e.g. my_tuple[0] .

Why is a tuple not callable?

To summarize, TypeError' tuple' object is not callable occurs when you try to call a tuple as if it were a function. To solve this error, ensure when you are defining multiple tuples in a container like a list that you use commas to separate them.


Video Answer


1 Answers

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)>
like image 161
Idodo Avatar answered Oct 28 '22 13:10

Idodo