I am trying to get a scatter plot in R. I have two factors (group and sex), and I want to show the sex in colors separately in the same graph (together with its confidence interval error bars. (Now all my data seems together without considering sex)
Here is my R code:
ggplot(data, aes(x=reorder(group_general, weight, color = sex,
FUN=mean), y=weight)) +
geom_jitter(colour="lightblue", alpha=1, width=0.1) +
geom_point(stat="summary", fun.y="mean") +
geom_errorbar(stat="summary", fun.data="mean_se", fun.args =
list(mult = 1.96), width=0) +
labs(x="Group", y="weight(mean + 95%CI)") +
theme_bw() +
theme(axis.text.x=element_text(angle=45, hjust=1))
Any recommendations?