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]
# plt.plot(subset['MONTH'], subset['VALUE'], c=colors[i])
# plt.show()
#Solution
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:
As this is the answer key (I got a similar error with my code) I would expect it to work. Kind of frustrating, I have brief periods of time I can do course work and to be stopped by something causes me to not be able to meet my goals.
What actually happened:
/dataquest/system/env/python3/lib/python3.4/site-packages/plotly/matplotlylib/renderer.py:390: UserWarning:
Bummer! Plotly can currently only draw Line2D objects from matplotlib that are in 'data' coordinates!
/dataquest/system/env/python3/lib/python3.4/site-packages/plotly/matplotlylib/renderer.py:487: UserWarning:
I found a path object that I don't think is part of a bar chart. Ignoring.