Legend show "u" and "p" instead of "Women" and "Men"

Screen Link: https://app.dataquest.io/m/147/improving-plot-aesthetics/6/hiding-tick-marks

Your Code:

fig, ax = plt.subplots()
ax.plot(women_degrees["Year"], women_degrees["Biology"], label="Women")
ax.plot(women_degrees["Year"], 100-women_degrees["Biology"], label="Men")
ax.tick_params(bottom="off",top="off",left="off",right="off")
ax.legend("upper right")
ax.set_title("Percentage of Biology Degrees Awarded By Gender")
plt.show()

What actually happened:
The output in the Legend is just u instead of Women and p instead of Men but i expected the output Women and Men.
Other details:
In the lesson befor, i wrote the same code and it displayed “Women” and “Men”

After it don’t works I copy and paste the answer and it display it correct.

fig, ax = plt.subplots()
ax.plot(women_degrees['Year'], women_degrees['Biology'], label='Women')
ax.plot(women_degrees['Year'], 100-women_degrees['Biology'], label='Men')

ax.tick_params(bottom="off", top="off", left="off", right="off")
ax.set_title('Percentage of Biology Degrees Awarded By Gender')
ax.legend(loc="upper right")

plt.show()

Hi @Desdakon, welcome to the community!

The difference in the code is the line for ax.legend():
Your code: ax.legend("upper right")
Solution code: ax.legend(loc="upper right")

It looks like without the loc= it’s just taking the 1st 2 letters and labeling each line. From what I get from the documentation, ax.legend is iterating over the string (treating it as an iterable list of characters), and using one character to label each line. Using loc= tells matplotlib where to put the legend for the axes.

Thank you,

After 6 hours of learning it is difficult to see.