【问题标题】:multiple legends setting legend key circle color多个图例设置图例键圈颜色
【发布时间】:2017-09-03 07:17:03
【问题描述】:

我有这个情节:

dates = c("2017-03-13","2017-03-13","2017-03-14","2017-03-14","2017-03-14")
value = c(5,6,7,8,9)
group = c("A","B","A","B","C")
size = c(10,20,30,40,50)
data =data.frame(dates= dates, value = value, group = group, size = size)
ggplot(data, aes(x = dates, y = value, group = group)) + geom_point(aes (color = as.factor(group), size= size ))+
 scale_color_manual(name="group",
                     labels = c(A="A",B= "B",C = "C"),
                     values = c(A="green",B="red" , C = "orange" )
  ) + theme(
    panel.background = element_rect(fill = "black", colour = "black"),
    legend.key = element_rect(colour = "black", fill = "black")
  )

有两个问题:

(1) 当前在尺寸图例中,圆圈为黑色,背景为黑色。如何将圆圈的颜色设置为红色,以便您可以看到黑色背景上的圆圈?

【问题讨论】:

  • 人分为三种。会数的人和不会数的人。

标签: r ggplot2


【解决方案1】:

您需要guide_legend中的override.aes来更改图例中的美学设置而不更改情节。

+ guides(size = guide_legend(override.aes = list(color = "red")))

【讨论】:

猜你喜欢
  • 2015-10-03
  • 2013-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-13
  • 2018-10-28
  • 2014-07-05
  • 2013-09-02
相关资源
最近更新 更多