【发布时间】:2021-09-11 18:05:30
【问题描述】:
在图表中,我有列和点。我正在尝试统一传说;我已经在秤上放了相同的名字,但它们仍然是分开的。有人可以帮我解决这个问题吗?
library(ggplot2)
X <- factor(c("a", "b"))
Y1 <- c(10, 15)
Y2 <- c(22, 23)
df <- data.frame(X, Y1, Y2)
ggplot(data = df, aes(x = X,
group = 1)) +
geom_col(aes(y = Y1,
fill = "Y1")) +
geom_line(aes(y = Y2,
color = "Y2")) +
geom_point(aes(y = Y2,
color = "Y2")) +
scale_fill_manual(name = "Legend",
values = "blue") +
scale_color_manual(name = "Legend",
values = "red")
【问题讨论】:
标签: r ggplot2 scale legend legend-properties