我如何更改ggplot2图例的标题? [英] How can I change the title of a ggplot2 legend?

查看:261
本文介绍了我如何更改ggplot2图例的标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找这里,但我无法弄清楚。



如何将单词类型更改为其他内容?

解决方案



  + labs(color =legend title)

到您的ggplot调用。
伟大的资源网站也是 ggplot2的谷歌组



编辑:这里假设颜色是图例中的美学,例如 qplot(X,Y,颜色= Z)。如果在图例中显示另一种美学,则将其用作参数,例如, + labs(fill =legend title)用于栅格/图像绘图。 b
$ b

更一般地说,如果你指定一个显式比例如 scale_colour_continuous ,你可以设置 scale_name 参数( warning ):在最近的版本 ggplot2 中,缩放参数的详细信息可能已更改; this描述的版本是0.9.2.1)。


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

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

解决方案

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).

这篇关于我如何更改ggplot2图例的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆