ggplot2 legend for abline and stat_smooth

前端 未结 3 756
生来不讨喜
生来不讨喜 2021-01-13 13:32

I have some problems with ggplot legends, here is my first code with only the legend for corrGenes, which is fine.

gene1=c(1.041,0.699,0.602,0.602,2.585,0.60         


        
3条回答
  •  -上瘾入骨i
    2021-01-13 14:25

    The show_guide=TRUE argument should display the legends for both geom_abline and stat_smooth. Try running the below code.

    plot= ggplot(data=DF,aes(x=gene1,y=BIME))+
    geom_point(aes(colour=corrGenes),size=5)+
    geom_abline(aes(colour="best"),intercept=0, slope=1, show_guide=TRUE)+
    stat_smooth(aes(colour="data"),method = "lm",se=FALSE, show_guide=TRUE)+
    scale_colour_manual(name="Fit", values=c("data"="blue", "best"="black"))+
    ylab("BIME normalized counts (log10(RPKM))")+
    xlab("gene1 normalized counts (log10(RPKM))")
    

提交回复
热议问题