I have a timeserie of 1351 values embedded into a pandas dataframe with two columns:
- date
- value
I want to add a unique color for each year to have a result who looks like this:
I tried to create a series with all years and pass it to the c
parameter:
df.plot(x='date', y='value', figsize=(15, 10), c=df.date.dt.year.astype('category'));
Unfortunately, I've got the error message:
1 2022
2 2022
3 2022
4 2022
...
1346 2010
1347 2010
1348 2010
1349 2010
1350 2010
Name: date, Length: 1351, dtype: category
Categories (13, int64): [2010, 2011, 2012, 2013, ..., 2019, 2020, 2021, 2022] is not a valid value for color
How can I assign a unique color for each year without creating a color palette manually?
I know you can use this trick with R how can I achieve it with python / pandas ?