Here is my data:
Food nutrient1 nutrient2 nutrient1se nutrient2se
Control 50 1 2.5 0.02
D1 100 1 4 0.05
D2 90 0.9 3 0.03
D3 100 0.9 6 0.04
My code is:
library(ggplot2)
ggplot (data = d, aes(x= nutrient2, y = nutrient1, group=Food))+
geom_point (aes (shape=Food, colour=Food), size=4, shape=c(15,16,17,18))+
geom_errorbarh(aes(xmin=nutrient2-nutrient2se, xmax=nutrient2+nutrient2se), length=0.2, colour="orange")+
geom_errorbar(aes(ymin= nutrient1-nutrient1se, ymax= nutrient1 +nutrient1se), width=0.2, colour="orange")+
= nutrient1-nutrient1se, ymax= nutrient1 +nutrient1se), width=0.2, colour="orange")+
scale_size_area()+
xlim(0, 1.5)+
ylim(90, 120)+
xlab("Total nutrient2 (g)") +
ylab("Total nutrient1 (g)") +
theme_update(plot.title = element_text(hjust = 0.5))+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "orange"))+
guides(color=guide_legend(override.aes=list(fill=NA)))+
plot.background=element_rect(fill="transparent",colour=NA),
legend.key = element_rect(fill = "transparent", colour = "transparent"))+
theme(axis.title.x = element_text(colour = "orange"),axis.title.y = element_text(colour = "orange"))
I need to match the legend's shapes with the points in the grouped scatter plot, could you please help me? Thanks