Exploratory Data Visualization: Multiple Plots

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']
legends = ['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=legends[i])
    
plt.legend(loc='upper left')
plt.show()

What I expected to happen:

I expected my plot to be the same as the answer check plot. I have inspected and could not catch the mismatch.

What actually happened:

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



1 Like

This is a possible bug on DataQuest’s side:

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

I experienced similar problems in:

  1. Multiple Plots: 11. Final Tweaks
    https://app.dataquest.io/m/143/multiple-plots/11/final-tweaks
colors = ['red', 'blue', 'green', 'orange', 'black']
legends = ['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=legends[i])
plt.title('Monthly Unemployment Trends, 1948-1952')
plt.xlabel('Month, Integer')
plt.ylabel('Unemployment Rate, Percent')
plt.legend(loc='upper left')
plt.show() ```

2. Bar Plots And Scatter Plots: Aligning Axis Ticks And Labels
[https://app.dataquest.io/m/144/bar-plots-and-scatter-plots/5/aligning-axis-ticks-and-labels](http://)

```num_cols = ['RT_user_norm', 'Metacritic_user_nom', 'IMDB_norm', 'Fandango_Ratingvalue', 'Fandango_Stars']
bar_heights = norm_reviews[num_cols].iloc[0].values
bar_positions = arange(5) + 0.75
tick_positions = range(1,6)
fig, ax = plt.subplots()
ax.bar(bar_positions, bar_heights, 0.5)
ax.set_xticks(tick_positions)
ax.set_xticklabels(num_cols, rotation=90)
ax.set_xlabel('Rating Source')
ax.set_ylabel('Average Rating')
ax.set_title('Average User Rating for Avengers: Age of Ultron (2015)')
plt.show()```

This code worked:
[https://app.dataquest.io/m/144/bar-plots-and-scatter-plots/9/benchmarking-correlation](http://)
```import matplotlib.pyplot as plt

fig = plt.figure(figsize=(5,10))
ax1 = fig.add_subplot(3,1,1)
ax2 = fig.add_subplot(3,1,2)
ax3 = fig.add_subplot(3,1,3)

sub_list = [ax1, ax2, ax3]
rat_list = ["RT_user_norm", "Metacritic_user_nom","IMDB_norm"]
ax_list = ["Rotten Tomatoes", "Metacritic", "IMDB"]

for i in range(3):
    sub_list[i].scatter(norm_reviews['Fandango_Ratingvalue'], norm_reviews[rat_list[i]])
    sub_list[i].set_xlabel('Fandango')
    sub_list[i].set_ylabel(ax_list[i])
    sub_list[i].set_xlim(0, 5)
    sub_list[i].set_ylim(0, 5)
    
plt.show()```

Please help fix the bug. Someone I know had similar issues with one question yesterday in List and Loop (3/13) of the Python Fundamental course.

Hello All,

It was happened to me as well and i tried refreshing and then still the issue remains the same. Alternatively i tried doing a simple experiment by taking the solution code from the answer and pasted in my editor then it allowed me to avoid this error.
The thing which makes me question is, though i written the same code which is there in the answers, but it didn’t allowed me with successful mission completion and ended up with same error which has mentioned above.

Finally i would like to conclude that i am bit confused with this logic.

Thanks
K!

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

Hi, I am unfortunately still getting an error when using the same strategy as above. This is the error I receive when using the same code as above. Even copying the solution listed identically, I still receive an error.

TypeErrorTraceback (most recent call last)
in ()
8 plt.plot(subset[‘MONTH’], subset[‘VALUE’], c=colors[i], label=legends[i])
9
—> 10 plt.legend(loc=‘upper left’)
11 plt.show()

TypeError: ‘str’ object is not callable

The same error happens in the next page as well, ‘Final Tweaks’.