我想将密度图图例中显示的框更改为线条,我知道我需要使用指南。但是,以下代码无效:
set.seed(0)
df <- data.frame(Income=c(rnorm(500,1000,200),rnorm(500,900,10)),Type=c(rep("A",500),rep("K",500)))
p2p <- ggplot(df,aes(x=Income))+geom_density(aes(colour=Type))+
guides(colour = guide_legend(override.aes = list(linetype = 1, shape = 3)))