我试图用两组(分别是形状和颜色)制作一个情节,但是" Cap W"与scale_fill_manual
颜色不对应。
install.packages("ggplot2")
library(ggplot2)
df <- data.frame(x = 1:5,
y = 4:8,
z = c("z1", "z1", "z2", "z2", "z3"),
w = c("w2", "w3", "w4", "w1", "w1"))
ggplot(df, aes(x, y, shape = z, fill = w)) +
geom_point(size = 6) +
scale_shape_manual(name = "Cap Z", values = c(21, 22, 24)) +
scale_fill_manual(name = "Cap W", values = c("black", "grey30", "grey60", "white")) +
theme_bw()
有关如何修复的想法吗?