Exploratory Data Visualization-multiple plots-10.adding a legend

Screen Link:
https://app.dataquest.io/m/143/multiple-plots/10/adding-a-legend

My Code:

fig = plt.figure(figsize=(10,6))
colors = ['red', 'blue', 'green', 'orange', 'black']
for i in range(5):
    start_index = i*12
    end_index = (i+1)*12
    subset = unrate[start_index:end_index]
    label = str(1948 + i)
    plt.plot(subset['MONTH'], subset['VALUE'], c=colors[i], label=label)
plt.legend(loc='upper left')

plt.show()

What I expected to happen:
I actually pasted the answer so I think it should work. Same problem for https://app.dataquest.io/m/143/multiple-plots/11/final-tweaks

What actually happened:

Your 1st plot doesn't match what we expected.



1 Like

This seems to be a bug as others seem to face a similar problem - Rejected answer

Someone from Dataquest, maybe @Sahil can probably look into it.

3 Likes

Hi @sunnybluecan,

Thank you for reporting the issue on screen 10, I will get it logged. The issue with screen 11 has already been logged. Probably both of these issues are related.

1 Like

Hi @Sahil! Having the same problem with this mission. Even copy-pasting the answer from the solution didn´t help.

3 Likes

Hi I got the same problem,
but it seems if I put codes after the originally showed ones, no editing on originals,
which means to repeat similar coding as it shows above and then put extra codes in it, it would be fine
hope it can help :slight_smile:

2 Likes

Thank you!

I was getting worried!

I experienced the same problem and the only way to solve it was following @sophiay_lsy9 instructions, which was copying the whole text in the answer section (even the lines before the #solution comment) and finally it worked. It is definitely a bug.

Hi @ksenia.kustanovich,

I have marked the mission as complete for you. Can you please confirm?

Thanks,
Sahil

Have there been any updates on this? i am also having this problem with screen 10 and 11

Hi All,

I am happy to announce this issue has been fixed. :tada:
Let me know if you are still experiencing this issue.

Best,
Sahil

1 Like

I think the plt.legend needs to be part of the for loop and thats why it is not working.

Hi @howard1,

Are you experiencing any issue in this mission screen? I just checked it, and it seems to be working fine on my end.

Best,
Sahil

No issues Sahil.
I just thought maybe it wasn’t working because the plt.legend was out of the for loop.
I guess it doesn’t matter but makes sense to put the plt.legend out of the for loop.
I put mine in the for loop and it worked correctly as well.
Thanks for checking in,
FYI. I did the data analst Nanodegree from udacity and I really like dataquest so much better.
THe projects at udacity were good. BUT, the teaching was terrible. So much better at dataquest…

1 Like