另一个ggplot传奇问题!
以下代码是我的愿望情节和图例顺序
TB.SIBER$Location1 <- factor(TB.SIBER$Location, level = c("Black Forest, NTU","Baoshan, Hsinchu","Zhongshan, Keelung", "Shiding, New Taipei"))
TB.SIBER$Group <- factor(TB.SIBER$Group, level = c("Amynthas aspergillum","Amynthas gracilis","Amynthas hupeiensis", "Amynthas incongruus","Amynthas robustus","Amynthas sp.","Pontoscolex corethrurus","Null","soil 0-5 cm","soil 15-20 cm","leaf litter"))
这是我的ggplot原始代码。我根据不同的物种创建了不同的层。
siber.biplot <- ggplot(TB.SIBER, aes(x=d13C, y=d15N, colour=Group, shape=Group))+
geom_point(alpha=0.6, size=4,shape= 16, color="firebrick4", show.legend = TRUE,data = subset(TB.SIBER, Group == 'Amynthas aspergillum'))+
geom_point(alpha=0.6, size=4,shape= 16, colour="green2", show.legend = TRUE,data = subset(TB.SIBER, Group == 'Amynthas gracilis'))+
geom_point(alpha=0.6, size=4,shape= 16, colour="forestgreen",data = subset(TB.SIBER, Group == 'Amynthas hupeiensis'))+
geom_point(alpha=0.6, size=4,shape= 16, colour="turquoise3",data = subset(TB.SIBER, Group == 'Amynthas incongruus'))+
geom_point(alpha=0.75, size=4,shape= 16, colour="blue2",data = subset(TB.SIBER, Group == 'Amynthas robustus'))+
geom_point(alpha=0.6, size=4,shape= 16, colour="maroon3",data = subset(TB.SIBER, Group == 'Amynthas sp.'))+
geom_point(alpha=0.5, size=3,shape= 16, colour="yellow2",data = subset(TB.SIBER, Group == 'Pontoscolex corethrurus'))+
geom_point(alpha=0.6, size=4,shape= 16, colour="darkorchid4",data = subset(TB.SIBER, Group == 'Null'))+
geom_point(alpha=0.8, size=2.5,shape= 0, colour="sandybrown", data = subset(TB.SIBER, Group == 'soil 0-5 cm'))+
geom_point(alpha=0.8, size=2.5,shape= 2, colour="red4", data = subset(TB.SIBER, Group == 'soil 15-20 cm'))+
geom_point(alpha=0.8, size=2.5,shape= 4, colour="orange4", data = subset(TB.SIBER, Group == 'leaf litter'))+
facet_wrap(.~Location1,ncol=2)+
labs(colour=NULL, shape=NULL)+
theme_bw()+
ylab(expression(delta^(15)-N))+
xlab(expression(delta^(13)-C))
siber.biplot
但是当我在 geom_point 中添加形状和颜色时,图例就消失了。
如何恢复图例并管理我想要的图例顺序?
请给我一些关于如何做到这一点的想法?
谢谢