# Storytelling Data Visualization on Exchange Rates: Plotting multiple years on 1 graph

Hello, all.

I’m wondering if there is an easy way to plot year-on-year in Matplotlib or Seaborn. Also, how many years is too many to put on one graph? After 3-5 it starts to look too busy to me.

My Code:

``````for year in range(1999,2001):
year_data = euro_to_dollar[euro_to_dollar['Time'].dt.year == year]
plt.plot(year_data['Time'],year_data['Rolling_Mean'],label = year)
plt.xticks(rotation=40)
plt.legend(bbox_to_anchor=(1.04,1), loc="upper left")
plt.show()
``````

What I expected to happen:
I was going for years overlapping,

What actually happened:

The years came out consecutively, just different colors

I realized after I ran it that I need some way to split the year from the month/day and I’ve searched and tried many options. So far the closest I’ve found is

``````for year in range(1999,2001):

year_data = euro_to_dollar[euro_to_dollar['Time'].dt.year == year]
plt.plot(year_data['Time'].dt.dayofyear,year_data['Rolling_Mean'],label = year)
plt.xticks(rotation=40)
plt.legend()
plt.show()
``````

But I can’t figure out how to change the x tick labels to anything but numbers from 1-365. Surely there’s a simpler way to do this.

Something like that?

``````import seaborn as sns
euro_to_dollar['year'] = euro_to_dollar['Time'].dt.year
sns.lineplot(data=euro_to_dollar, x="Time", y="Rolling_Mean", hue="year")``````

I tried that, and it works, I suppose, but it still makes it one continuous plot, instead of 2-3 on top of each other (in different color) the same 12-month period. Is that just not a good way to to it?

You mean that you want 1 different chart for each year ? So in this case this is a just a matter of `plt.show()` indentation. You have to ask for showing the plot inside you `for` loop.

``````for year in range(1999,2001):
year_data = euro_to_dollar[euro_to_dollar['Time'].dt.year == year]
plt.plot(year_data['Time'].dt.dayofyear,year_data['Rolling_Mean'],label = year)
plt.xticks(rotation=40)
plt.legend()
plt.show()``````