The code is wrong as per final output but both are same and correct!

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

My Code:

import matplotlib.pyplot as plt
fig = plt.figure(figsize=(10,6))
colors = ['red', 'blue', 'green', 'orange', 'black']
years=[1948,1949,1950,1951,1952]
for i in range(5):
    start_index = i*12
    end_index = (i+1)*12
    subset = unrate[start_index:end_index]
    # plt.plot(subset['MONTH'], subset['VALUE'], c=colors[i],label=str(years[i]))
    plt.plot(subset['MONTH'], subset['VALUE'], c=colors[i],label=str(1948+i))
plt.legend(loc="upper left")
plt.show()

What I expected to happen:
The output is exactly the same as the actual answer therefore, it should not show any error on the submission.

What actually happened:

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

On submission, it shows the error above. I tried with both the plt.plot() ways as mentioned in the code but the error still remains. If this is because of

Hello @joshi.ananya.joshi1,

There is no problem with your code, I think the problem is with the DQ grader for that mission. Same thing happened to me.

If you comment this line of code and resubmit, It should mark your code correct.

Let me know if this helps.

@Sahil, @nityesh, Kindly look into this.

Yes it is submitted correctly now. But, it’s clearly mentioned in the instructions that we need to place a legend on upper left side of the plot. (Is this a bug?)

@joshi.ananya.joshi1,

It is a bug, you can submit a bug report by filling a ticket here.

Happy learning!

Hello,
Similar is happening with the next screen and the trick provided above (commenting the plt.legend() ) is also not working with it.

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.title("Monthly Unemployment Trends, 1948-1952")
plt.xlabel("Month, Integer")
plt.ylabel("Unemployment Rate, Percent")
plt.show()

@joshi.ananya.joshi1,

It is the bug.

The correct Solution to 9/13 is accepted for 10/13
The correct Solution to 10/13 is accepted and marked correct for 11/13.

So if you want the grader to mark your answer for 11/13 correct, you have to input the correct solution to 10/13 which is what is in your first post.

Please fill a ticket using a link in my previous reply.

2 Likes

This is possibly a bug on DQ side. I believe this was already addressed here

Kindly check it out.

Best
K!

1 Like

Got it, thanks a lot mate.

3 Likes

@joshi.ananya.joshi1, You are welcome. Do you mind marking the reply as a solution?

1 Like

This is amazing! @doyinsolamiolaoye,

I am sure this will help the content team to find the issue quickly. I will add it to the bug report.

Thanks,
Sahil

1 Like

Can somebody at DQ please fix this? We are actually paying for this :slight_smile:

1 Like

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