I have a dataframe that has 3 numerical values
T
kWh
Month
The T
variable holds values between 1 and 48 and the kWh
variable is discrete.
I'm trying to display a line graph that shows the average kWh
at each T
for every Month
by having an individual line for each Month
(average kWh
on the Y axis and T
on the X axis.)
My approach was the following
grouped_by_t = group_by(df, T)
summarised_by_t = summarise(grouped_by_t, Average=mean(kWh, na.rm=TRUE), Month=Month)
And finally plotting it like so
ggplot(data=summarised_by_t, aes(x=T, y=Average, group=Month, color=Month)) + geom_line()
Unfortunately, this just displayed one line with a colour gradient at the edge of the plot which isn't what I want.