pythonmatplotlib

Why do I get 'str' object is not callable?


I did this plot and it worked. The day after I ran it and I got this error:
TypeError: 'str' object is not callable.

plt.plot(A2, A15, color="black", label="TRC - P1", marker="o")
plt.xlabel("Amostras")
plt.ylabel("TRC (%)")
plt.title("TRC da P1")
plt.yticks([0, 10, 20, 30, 40, 50, 60, 70])
plt.xticks(rotation=60)

Following the error I have got enter image description here


Solution

  • I would guess that you defined somewhere in your notebook something like plt.xlabel = "something". This could also happened before you run this code shown. Try to close the Notebook and restart your Kernel. After restarting run your code shown and everything should be fine.

    If using jupyter notebook then click on Run tab and select restart kernel and run all cells