ggplot2:使用scale_colour_brewer()并手动指定图例名称/输入标签 [英] ggplot2: use scale_colour_brewer() and specify legend name / entry labels manually

查看:2074
本文介绍了ggplot2:使用scale_colour_brewer()并手动指定图例名称/输入标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 scale_colour_brewer() scale_fill_brewer()来通过brewer调色板指定填充或颜色:

I want to use scale_colour_brewer() and scale_fill_brewer() to specify the fill or colours via the brewer palette:

diagram <- diagram + scale_colour_brewer() + scale_fill_brewer()

不过,我仍然想手动设置图例标签及其条目。我以前通过这样做:

Nevertheless, I still want to set the legend label and its entries manually. I did so formerly via:

diagram + 
  scale_colour_manual(name="Cumulative Percentage", 
  values=c("#d7191c","#fdae61","#000000","#abdda4","#2b83ba"), 
  labels=c("GN","GN1","GN2","GN3","GN4"))

如何使用自动调色板功能,图例名称和手动输入标签?

How can I use the auto-palette feature, while still setting the legend name and the entry labels manually?

谢谢!

Thanks!

推荐答案

您也可以在 scale_colour_brewer()中使用相同的参数 name = labels =

You can use the same arguments name= and labels= also in scale_colour_brewer().

+ scale_colour_brewer(name="Cumulative Percentage", 
                      labels=c("GN","GN1","GN2","GN3","GN4"))

这篇关于ggplot2:使用scale_colour_brewer()并手动指定图例名称/输入标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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