Remove legend ggplot 2.2

前端 未结 4 1471
太阳男子
太阳男子 2020-12-02 03:59

I\'m trying to keep the legend of one layer (smooth) and remove the legend of the other (point). I have tried shutting off the legends with guides(colour = FALSE)

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 04:46

    from r cookbook, where bp is your ggplot:

    Remove legend for a particular aesthetic (fill):

    bp + guides(fill=FALSE)
    

    It can also be done when specifying the scale:

    bp + scale_fill_discrete(guide=FALSE)
    

    This removes all legends:

    bp + theme(legend.position="none")
    

提交回复
热议问题