Heavy Traffic Guided Project -- .xlim error

Screen Link: Learn data science with Python and R projects

My Code:

plt.figure(figsize=(8, 4))
#Plotting daytime data
plt.xlim((0, 8000))
plt.ylim((0, 8000))
plt.title("Day Time Traffic")
plt.xlabel("Traffic Volume")

#Plotting nighttime data
plt.xlim ([0, 8000])
plt.ylim ([0, 8000])
plt.title("Night Time Traffic")
plt.xlabel("Traffic Volume")

What actually happened:

TypeError                                 Traceback (most recent call last)
<ipython-input-68-c9c1d8eb3519> in <module>
      3 plt.subplot(1,2,1)
      4 plt.hist(day["traffic_volume"])
----> 5 plt.xlim([0, 8000])
      6 plt.ylim([0, 8000])
      7 plt.title("Day Time Traffic")

TypeError: 'tuple' object is not callable

I initially ran the code without the .xlim and .ylim (because I forgot to add them in) and the code was working fine. Ever since I added it, it stopped working. I have tried using (()), () and no brackets at all but nothing seems to work.

I tried to remove these 2 lines altogether but then it showed the same error on the .xlabel line of code eveb though the code had previously worked. Can anyone point out where I am going wrong?

I ran your code and it’s working without any issues. I would recommend restarting the Kernel and running all the code cells till this point again, just to make sure it’s not a temporary issue.

If it doesn’t work, then it would help if you shared the rest of your code as well.

Thanks, restarting the kernel did the trick.