I am plotting two lines on same plot with sme x axis by following lines. i am implementing the lower line but unable to see colors and legend
ggplot(final, aes(x = Date)) + geom_line(aes(y = cocastock)) + geom_line(aes(y = procterstock)) + scale_color_manual(values = c(cocastock = '#008B00', procterstock = '#FFFFFF'))
also tried
ggplot(final, aes(x = Date)) + geom_line(aes(y = cocastock)) + geom_line(aes(y = procterstock)) + scale_color_manual(values = c('#008B00','#FFFFFF'))
but dosen't work
scale_colour_manual
only works when you have specified colour in aes
, hence you need:
ggplot(final, aes(x = Date)) +
geom_line(aes(y = cocastock, colour = "cocastock")) +
geom_line(aes(y = procterstock, colour = "procterstock")) +
scale_color_manual(values = c(cocastock = '#008B00', procterstock = '#FFFFFF'))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.