How can I change the legend linetype in ggplot2?
问题 I have this simple plot where I cannot change the linetype in the legend according to the linetype in the plot using scale_linetype_manual. The code to produce the plot is : library(ggplot2) x_1 <- rep(0:6, each = 2) pdf_1 <- c(0,0.05,0.05,0.1,0.1,0.15,0.15,0.3,0.3,0.25,0.25,0.15,0.15,0) x_2 <- rep(3:9, each = 2) pdf_2 <- c(0,0.05,0.05,0.1,0.1,0.15,0.15,0.3,0.3,0.25,0.25,0.15,0.15,0) data_1 <- data.frame(x_1, pdf_1,x_2,pdf_2) ggplot()+ geom_line(data=data_1,aes(x=x_1, y=pdf_1, color=