Help with an error please? (Data viz, matplotlib)

Hi guys. Currently doing the “Intro to Data Visualization with Python” course. I’m working on the “Make a Line Chart for Research” project bit, working in a Jupyter notebook and all, and I can’t figure something out. I’ve looked online but failed to figure out what I’m doing wrong.

I’m trying to label the x and y axes for a chart. This is what I put, underneath the line of code for the title:

plt.xlabel('Month')
plt.ylabel('Precipitation (in.)')

The error is regarding the first line (x axis) and says there’s a Type Error, and that the “str object is not callable.” I’ve tried looking this up but it seems like, with what I’ve searched and found, I’m doing things right? I can’t figure out why this error keeps being thrown. Anyone know what I’m doing wrong? Thanks a lot.

try restarting the kernels (in order) and then this one to see if the error still exists. (including reimporting import matplotlib.pyplot as plt ).

Also, what is all your code? Did you label x & y axis before or after you set the ax1.set_xticks(x_values) & ax1.set_xticklabels(months) ?

1 Like

Hey. It ended up being a super easy fix, and all I had to do was reimport some of the earlier code. I’m still getting used to all of this, so to be honest I didn’t even think of reimporting, and I wouldn’t have done it if it wasn’t for your quick suggestion, so thank you so much :joy: :joy:

2 Likes

Sometimes the kernels time out (for lack of a better word) and you have to restart them.

Happy coding!

1 Like