所以事情就是这样:我有一个带有美学映射的图(齿轮,hp,col = cyl)+ geom_line和geom_point
data(mtcars)
library(ggplot2)
ggplot(mtcars, aes(as.factor(gear), hp, col = as.factor(cyl))) +
geom_line() +
geom_point(aes(shape = as.factor(cyl))) +
facet_grid(cyl~.) +
scale_color_manual(values = c("red", "black", "goldenrod"))
这很好用。当我想手动标记图例(指南)
时出现问题ggplot(mtcars, aes(as.factor(gear), hp, col = as.factor(cyl))) +
geom_line() +
geom_point(aes(shape = as.factor(cyl))) +
facet_grid(cyl~.) +
scale_color_manual(values = c("red", "black", "goldenrod"), name = "Cylinder)
它拉开图例并将其分成两个:圆柱体(带有cols)和as.factor(cyl)形状。如何摆脱as.factor(cyl)或保持图例组合并仍然手动重命名?我想我只需要转移一些东西......
任何帮助将不胜感激!