1

When I try to change y-label in pyplot I get an error. 'str' object is not callable It is strange as I am able to change the x-label without an issue.

I am confused as renaming the xlabel works, but y doesn't.

plt.subplot(2,1,1)
plt.hist(asia2007["gdpPerCapita"],20)
plt.subplot(2,1,2)
plt.hist(europe2007["gdpPerCapita"],20)
plt.xlabel("Europe")
plt.ylabel("Freq")
plt.show()

I expect a graph with renamed Y label, but it throws an error.

----> 6 plt.ylabel("freq")

TypeError: 'str' object is not callable
DavidG
  • 24,279
  • 14
  • 89
  • 82
Marcel
  • 11
  • 3
  • You have probably done `plt.ylabel = "something"` somewhere in your code. Remove it and try again (restart your kernel if using jupyter) – DavidG Jan 24 '19 at 11:31
  • Can you post more (complete) code which reproduces the problem if it persists even after DavidG's suggestion? – Sheldore Jan 24 '19 at 11:35
  • https://stackoverflow.com/a/33925268/5851928 – DavidG Jan 24 '19 at 11:37
  • @DavidG I did not have 'plt.ylabel="whatever"' anywhere, but restarting kernal has worked, thanks very much! – Marcel Jan 24 '19 at 11:39

0 Answers0