I want to plot proper graph with lable, title and legend. here is my attempt to produce legend. but why this error comeout. is there extra package I missed to load? Details on my data available here . Kindly help.. Thank you
library(ggplot2)
ggplot() +
geom_line(data = Press_1000, aes(as.Date(date), temp_c), color = "darkblue") +
geom_line(data = Press_925, aes(as.Date(date), temp_c), color = "red") +
scale_color_discrete(name = "Pressure Level", labels = c( "1000", "925"))
#graph plotted without legend
ggplot() +
geom_line(data = Press_1000, aes(as.Date(date), temp_c), color = "Y1") +
geom_line(data = Press_925, aes(as.Date(date), temp_c), color = "Y2") +
scale_color_manual(values = c('Y1' = 'darkblue','Y2' = 'red')) +
labs(color = "Pressure Level")
#Error in grDevices::col2rgb(colour, TRUE) : invalid color name 'Y1'
ggplot() +
geom_line(data = Press_1000, aes(as.Date(date), temp_c), color = "a") +
geom_line(data = Press_925, aes(as.Date(date), temp_c), color = "b") +
scale_color_manual(name = "Colors", values = c("a" = "blue", "b" = "red"))
#Error in grDevices::col2rgb(colour, TRUE) : invalid color name 'a'