Only display specific labels of a ggplot legend

喜夏-厌秋 提交于 2019-12-06 16:37:59

If you are open to having any color other than red:

ggplot(df) +
    geom_point(aes(x, y, color = special)) + scale_size(guide = "none") + 
    scale_color_discrete(breaks="special") + labs(color = "") +
    theme_bw()

EDIT :

cols <- c("normal" = "black","special" = "red")
gg <- ggplot(df) + geom_point(aes(x, y, color = special)) + labs(color = "") + theme_bw()
gg + scale_colour_manual(values = cols, limits = "special")

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!