首页 > 解决方案 > 手动将图例添加到 ggplot2 绘图

问题描述

我正在尝试向下面显示的图和数据集添加图例。我已经尝试了这里建议的一些修复,但它似乎不起作用。非常感谢您的帮助!

数据

图形

ggplot()+
geom_point(data = Bacteria.Killing.Master, aes(x=Conc, y=X1121.2), color = "deepskyblue4", size = 3, shape = 16 )+
geom_line(data = Bacteria.Killing.Master, aes(x=Conc, y=X1121.2), color = "deepskyblue4")+
geom_point(data = Bacteria.Killing.Master, aes(x=Conc, y=X1121.5), color = "indianred4", size = 3, shape = 18)+
geom_line(data = Bacteria.Killing.Master, aes(x=Conc, y=X1121.5), color = "indianred4")+
geom_point(data = Bacteria.Killing.Master, aes(x=Conc, y=X1121.7), color = "springgreen4", size = 3, shape = 15)+
geom_line(data = Bacteria.Killing.Master, aes(x=Conc, y=X1121.7), color = "springgreen4")+
labs(y = "Bacterial Cells/mL", x = "Concentration of H2O2", color = "Legend")+
theme(plot.title = element_text(hjust = 0.5))+
ggtitle("H2O2 Bacteria Killing")+
scale_color_manual(values = c("deepskyblue4", "indiannred4", "springgreen4"))

标签: rggplot2

解决方案


推荐阅读