I want to add legend to my plot using the ggplot2 package,
below is the code I tried.
all_plot <- ggplot(rawData, aes(x=c(1:670))) +
geom_line(aes(y = DO1), color = 'DO1') +
geom_line(aes(y = DO2), color = 'DO2') +
geom_line(aes(y = Controlling.DO), color = 'Controlling.DO')+
ggtitle("Plot of ControllinDO changing in between DO1 and DO2", )+
labs(x="No of Observations", y="DO(Dissolved Oxygen)")+
scale_color_manual(
name ='title',
breaks = c('DO1','DO2','Controlling.DO'),
values = c('DO1'='darkblue','DO2'='red','Controlling.DO'='green')
)
all_plot
This is the error I'm getting
#Error in `geom_line()`:
#! Problem while converting geom to grob.
#ℹ Error occurred in the 1st layer.
#Caused by error: