0

I have the following code to make a graph with two lines. Although lines appear correctly, the legend does not appear at all. Any idea what I am doing wrong? Thanks

ggplot2::ggplot() +   
ggplot2::geom_line(data = Output_table$X1, ggplot2::aes(x=date, y=True), color = "red") +    
ggplot2::geom_line(data = Output_table$X1, ggplot2::aes(x=date, y=Actual), color = "black") +    
ggplot2::geom_hline(yintercept=0) +   
ggplot2::xlab('Dates') +   
ggplot2::ylab('Productivity') +   
ggplot2::ggtitle("Graph for myself") +   
ggplot2::scale_colour_manual(name="legends", values= c("True","Actual") )
Telis
  • 311
  • 1
  • 9
  • 1
    As a general rule: If you want to have a legend you have to map on aesthetics, i.e. move `color=..` inside `aes()` and set your colors via `scale_color_manual` or even better reshape your data to long or tidy format. – stefan Mar 10 '23 at 11:35

0 Answers0