简体   繁体   中英

Trying change legend title and text in ggplot2

I'm trying to make a plot with the legend title as "Condition" and the subsequent condition names renamed to just "Deviant" and "Standard". The other stack overflow answers were not working for me. I tried scale_fill_manual and now 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"))

If anyone can help me, it would be greatly appreciated. Attached is the plot I've currently made. I just want to change the legend text. 在此处输入图片说明

The grouped aesthetics are colours, not shapes.

If you change scale_shape_discrete to scale_colour_discrete it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM