How can I change the title of a ggplot2 legend?

后端 未结 4 745
小蘑菇
小蘑菇 2020-12-25 12:38

I was looking here but I can\'t figure it out.

How can I change the word \"type\" to something else?

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-25 13:15

    Add either:

    + scale_fill_discrete(name="Title", labels=c("1","2","3"))
    

    or

    + scale_colour_discrete(name="Title", labels=c("1","2","3"))
    

    depending on the geom.

    I recommend you look into the ggplot2 cheatsheet. https://www.rstudio.com/wp-content/uploads/2015/03/ggplot2-cheatsheet.pdf

提交回复
热议问题