我正在尝试让scale_color_manual()在ggplot2中工作,但我得不到颜色。
我正在遵循这个link中的示例
我的数据集是由df提供的
structure(list(cond = structure(1:3, .Label = c("A", "B", "C"
), class = "factor"), yval = c(2, 2.5, 1.6)), .Names = c("cond",
"yval"), class = "data.frame", row.names = c(NA, -3L))如果我使用示例中的代码来制作条形图,它就能正常工作
ggplot(df, aes(x=cond, y=yval, fill=cond)) + geom_bar(stat="identity") +
scale_fill_manual(values=c("red", "blue", "green"))

我修改了代码来绘制散点图,我现在看不到彩色的点。
ggplot(df, aes(x=cond, y=yval)) + geom_point() +
scale_color_manual(values=c("red", "blue", "green"))

这可能是微不足道的,但我很难找到我在这里做错了什么。
任何帮助都将不胜感激!
谢谢
发布于 2015-12-01 05:33:36
根据上面的评论,我需要将color映射到一个变量,如下所示
ggplot(df, aes(x=cond, y=yval, color = cond)) + geom_point() +
scale_color_manual(values=c("red", "blue", "green"))https://stackoverflow.com/questions/34008319
复制相似问题