How can I change the title of a ggplot2 legend?

后端 未结 4 723
小蘑菇
小蘑菇 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:23

    Add

    + labs(colour = "legend title") 
    

    to your ggplot call. Great resource site is also google group for ggplot2.

    edit: this assumes that colour is the aesthetic in the legend, e.g. qplot(x,y,colour=z). If another aesthetic is being shown in the legend, use that as the argument instead, e.g. + labs(fill = "legend title") for a raster/image plot.

    More generally, if you specify an explicit scale such as scale_colour_continuous, you can set the scale_name argument (warning: the details of the arguments to scales may have changed in recent releases of ggplot2; this description is of version 0.9.2.1).

提交回复
热议问题