Guided Project: Visualizing Earnings Based On College Majors >>major label

Hi,

Why I cannot get major labels on the x-axis?

Many thanks in advance.

1 Like

Hi @nantika.ngr,

You are calling .plot.bar() on a Series, you need to use it on the recent_grads[163:] DataFrame. So change your code to this:

recent_grads[163:].plot.bar(x="Major", y="ShareWomen", legend=False)
image

Hope this helps :slightly_smiling_face:

Best,
Sahil

1 Like

Hey sahil!
Why here we used major ??? in X columns ? and why we using legen=false, there was no evidence of legend=false in the project learn section.

and why everyone is using recent_grads[163:] ???
where in the instruction its clearly mention
Use bar plots to compare the unemployment rate ( Unemployment_rate ) from the first ten rows and last ten rows of the recent_grads dataframe.

1 Like

Hi @tusharsingh00,

Since the plot used in this topic is related to the first instruction, I will use it help you with your query.

Use bar plots to compare the percentages of women ( ShareWomen ) from the first ten rows and last ten rows of the recent_grads dataframe.

Why are we using the Major column as x-axis values?

In the recent-grads.csv dataset, each row represents a major. This is why we used that column as x-axis values to compare the percentages of women. None of the other columns would make sense.

Why are we using legend=False?

There is no need to use legend=False. However, if we don’t use it, the plot will appear like this:

As you can see, the legend doesn’t make much sense here.

Why are we using recent_grads[163:]?

If you execute recent_grads.tail(10), you will see that the last 10 rows start from index label 163. So we are using it here. However, it’s not necessary to explicitly use the starting index, we can just do:
recent_grads.tail(10).plot.bar(x="Major", y="ShareWomen", legend=False) to obtain the same results.

I hope it helps :slightly_smiling_face:.

Best,
Sahil

1 Like

Thank You Sahil for helping and clearing my doubts. :slight_smile:

1 Like