Say I have this table in a dataframe:
DATE SUNHOUR YEAR
--- ---------- --------- ------
281 2018-10-09 11.1 2018
29 2018-01-30 6.5 2018
266 2018-09-24 6.2 2018
115 2018-04-26 13.4 2018
69 2018-03-11 7.3 2018
158 2019-06-08 13.7 2019
287 2019-10-15 8.5 2019
177 2019-06-27 15.9 2019
136 2019-05-17 11.5 2019
59 2019-03-01 10.1 2019
This will give me a scatterplot:
df.plot.scatter(x='DATE', y='SUNHOUR')
Now, when I look at the documentation, I read that the parameter c
can take a column name or position whose values will be used to color the marker points according to a colormap. So I thought this would work to have a different color for each year:
df.plot.scatter(x='DATE', y='SUNHOUR', c='YEAR')
But this returns:
ValueError: 'c' argument must be a color, a sequence of colors, or a sequence of numbers, not ['2018' '2018' '2018' '2018' '2018' '2019' '2019' '2019' '2019' '2019']
What am I missing?