https://www.codecademy.com/practice/projects/roller-coaster
so i am creating a function that takes n numbers and a dataframe as an argument to graph the top ranked roller coasters from 2013 to 2018. this is what i have so far and it works but the legend covers too much of the graph, also the colors of the lines start to duplicate after five. how do i make sure each coaster has a unique color and the legend is off of the chart?
def top_coaster_graph(n, df):
top_n_rankings = df[df[‘Rank’] <= n]
fig = plt.figure(figsize=(10, 20))
fig, ax = plt.subplots()
for coaster in set(top_n_rankings[‘Name’]):
coaster_rankings = top_n_rankings[top_n_rankings['Name'] == coaster]
ax.plot(coaster_rankings['Year of Rank'], coaster_rankings['Rank'], label= coaster)
plt.legend()
plt.show()
print(top_coaster_graph(10, wood_rankings))