[HELP} Unable to display axis labels

Hi, I am working on Graphing in Python: Matplotlib but unable to display axis labels for AX1 & AX2.
I am hitting an error for the 2 lines of code in bold, inserted for reference here

plt.ylabel(‘limes sold’).
I don’t seem to be able to display the axis labels. Much help is needed to teach the newbie me what happened :s … Thank you so much!

File “script.py”, line 27, in
TypeError: ‘str’ object is not callable"

import codecademylib

from matplotlib import pyplot as plt

months = [“Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”, “Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec”]

visits_per_month = [9695, 7909, 10831, 12942, 12495, 16794, 14161, 12762, 12777, 12439, 10309, 8724]

numbers of limes of different species sold each month

key_limes_per_month = [92.0, 109.0, 124.0, 70.0, 101.0, 79.0, 106.0, 101.0, 103.0, 90.0, 102.0, 106.0]

persian_limes_per_month = [67.0, 51.0, 57.0, 54.0, 83.0, 90.0, 52.0, 63.0, 51.0, 44.0, 64.0, 78.0]

blood_limes_per_month = [75.0, 75.0, 76.0, 71.0, 74.0, 77.0, 69.0, 80.0, 63.0, 69.0, 73.0, 82.0]

create your figure here


ax1 = plt.subplot(1, 2, 1)

x_values = range(len(months))

plt.plot(x_values, visits_per_month, marker=“o”)





plt.title(“Page Visits Per Month”)

ax2 = plt.subplot(1, 2, 2)


plt.ylabel(‘limes sold’)



plt.plot(x_values, key_limes_per_month, color=“purple”)

plt.plot(x_values, persian_limes_per_month,color=“green”)

plt.plot(x_values, blood_limes_per_month,color=“red”)

plt.legend([“key limes”, “persian limes”, “blood limes”])

plt.legend([“Key Limes”, “Persian Limes”, “Blood Limes”])

plt.title(“Limes sold per month”)



If you’re posting code to the forums please see How do I format code in my posts? which gives in better formatting, keeps indentation and so on.

The names you’ve used plt.xlabel and plt.ylabel are functions. You should call them with the relevant string plt.xlabel("some string"). By assigning them you’ve masked the original function with a string (hence the unexpected error when you try to use them the second time around).

1 Like

thank you so much! sorry for the delayed replies. I definitely will look into what you have suggested and noted on the format code in the posts! Have an awesome week ahead!

1 Like