Draculin
Draculin

Reputation: 25

"TypeError: 'str' object is not callable" error while using Jupyter Notebook

I tried to plot a graph using pyplot from matplotlib and everything went fine until I tried to add the title.

from matplotlib import pyplot as plt
a = [1, 4, 8]
b = [1, 9, 18]
plt.plot(a, b)
plt.title("Title")
plt.xlabel("x")
plt.ylabel("y")
plt.show()

The code works fine except the title, from which an error is displayed as follows:

        TypeError                                 Traceback (most recent call last)
    <ipython-input-25-a1c519e5c0a1> in <module>
          4 plt.xlabel("X")
          5 plt.ylabel("Y")
    ----> 6 plt.title("title")
          7 plt.show()

TypeError: 'str' object is not callable

BTW, I am running this using Jupyter notebook

Upvotes: 0

Views: 9364

Answers (2)

Camue
Camue

Reputation: 481

I had this error twice on the Jupyter notebook. Restart your anaconda or better: from the kernel tab restart and run all. This should work

Upvotes: 4

DrFahizzle
DrFahizzle

Reputation: 67

Restart your kernel. It’s a common error.

Upvotes: 2

Related Questions