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.
Screen Link:
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.