plt.xlabel=('Month') not working

Screen Link:
https://app.dataquest.io/m/142/line-charts/9/adding-axis-labels-and-a-title

My Code:

# Generate the same line chart from the last screen that visualizes the unemployment rates from 1948.
x_values = unrate['DATE'].head(12)
y_values = unrate['VALUE'].head(12)
plt.plot(x_values, y_values)
plt.xticks(rotation=90)
# Set the x-axis label to "Month".
plt.xlabel=('Month')
# Set the y-axis label to "Unemployment Rate".
plt.ylabel('Unemployment Rate')
# # Set the plot title to "Monthly Unemployment Trends, 1948".
plt.title('Monthly Unemployment Trends, 1948')
# Display the plot.
plt.show()

What I expected to happen:

The x-axis label should have change to "Month"

What actually happened:

Nothing.

The plt.xlabel=('Month') does not seem to work, because the label on the x-axis does not change.
Can anyone tell me how to fix this, or any workaround?
I used a different browser as well but with the same result.
Thanks.

Hi @annalisa:

You used
plt.xlabel=('Month')

The correct syntax should be
plt.xlabel('Month') with no = sign since there is no assignment of values into variables. You can also find out more about its uses using the documentation.

Hope this helps!

2 Likes

Thanks a lot! I totally missed that!

no worries @annalisa! Happy Pythoning!

Actually that did not fix the problem, now I have this error:

Hi @annalisa

I managed to run your code successfully. Maybe you could rerun it.

If it still does not work you could try this:
For part 7/11 of the mission, you should already assign the slice to another variable as shown in the solution for part 7 below.
image
Thereafter you can then make use of the variable first_twelve .

Hope this helps!

I just re-run it and it worked, without changint anything… literally opened the screen and rerun… Thanks for looking into it though! :blush:

no problem. Sometimes these things happen!