I hope to make custom legend for my graph, and I referenced this two posts posts posts
I tried it, but it doesn't work
g2=ggplot(data=juga, aes(x=Date, group=0))+
geom_line(aes(y=Dow),colour="cornflowerblue")+
geom_line(aes(y=NASDAQ),colour="firebrick2")+
geom_line(aes(y=S.P.500),colour="gold2")+
geom_line(aes(y=Nikkei.225),colour="gray69")+
geom_line(aes(y=Shanghai),colour="forestgreen")+
geom_line(aes(y=KOSPI),colour="black")+
xlab("Dates") +ylab("Values")+
ggtitle("Juga graph")
g2
This is my original codes and its graph looks like this
To add legend, I changed codes like this
cols <- c("A"="cornflowerblue","B"="firebrick2","C"="gold2", "D"="gray69", "E"="forestgreen", "F"="black")
g2=ggplot(data=juga, aes(x=Date, group=0))+
geom_line(aes(y=Dow),colour="A")+
geom_line(aes(y=NASDAQ),colour="B")+
geom_line(aes(y=S.P.500),colour="C")+
geom_line(aes(y=Nikkei.225),colour="D")+
geom_line(aes(y=Shanghai),colour="E")+
geom_line(aes(y=KOSPI),colour="F")+
scale_colour_manual(values=cols)+xlab("Dates") +ylab("Values")+
ggtitle("Juga graph")
g2
But this code makes erros
Error in grDevices::col2rgb(colour, TRUE) : invalid color name 'A'
How can I fix them?