尝试更改ggplot2中的图例标题和文本

时间:2018-11-09 16:39:48

标签: r ggplot2 legend

我正在尝试制作一个图例,其图例标题为“ Condition”,随后的条件名称重命名为“ Deviant”和“ Standard”。其他堆栈溢出答案不适用于我。我尝试了scale_fill_manual,现在尝试了scale_shape_discrete。

ggplot(data = vintscondensed, aes(x = factor(vint, levels = 
    c("zero","one", "two", "three", "four", "five", "six", "seven", 
    "eight", "nine")), y = value, group = BinLab)) + 
  geom_line(aes(color = BinLab)) + 
  geom_point() + 
  labs(x = "Vicintiles", y = "ms", linetype = "Trial Type") + 
  theme(text = element_text(size = 20)) + 
  theme_bw() + 
  scale_shape_discrete(name = "Condition", breaks = c("Deviant_RT", "Standard_RT"), labels = c("Deviant", "Standard"))

如果有人可以帮助我,将不胜感激。附件是我当前绘制的图。我只想更改图例文本。 enter image description here

1 个答案:

答案 0 :(得分:0)

分组的美学是颜色,而不是形状。

如果将scale_shape_discrete更改为scale_colour_discrete,则应该可以。