我正在尝试在ggplot上更改图例的标签,其中有2个aes的图例。 使用scale_file_manual,它可以工作,但仅适用于两个图例之一。我想我应该使用我已经用来删除标题的“指南”,同时也删除第三只aes的图例,但是我没有做到这一点。 你有解决办法吗?
这是我的代码:
p <- ggplot(data, aes(x = Nb))
p + geom_ribbon(aes(ymin = Sandwich.min, ymax = Sandwich.max, fill = 'grey70',alpha=0.8)) +
geom_ribbon(aes(ymin = Assiette.min, ymax = Assiette.max, fill = '#6495ED80',alpha=0.8)) +
geom_line(aes(y = Pizza, col = '#FF7F24')) +
geom_line(aes(y = Sushis, col = '#228B22')) +
labs(title = "Business lunch cost by number of participants",
x = "Number of participants",
y = "Price (Euros)") +
scale_x_continuous(breaks=seq(1,20,1)) +
scale_y_continuous(breaks = seq(0,300,50)) +
theme_light() +
theme(plot.title = element_text(size = 12, hjust = 0.5)) +
guides(alpha = FALSE, colour = guide_legend(" "), fill = guide_legend(" ")) +
scale_fill_manual(
values=c('#6495ED80','grey70'),
labels=c("Assiettes","Sandwiches"))