This is a test version of Biostars. For the public version, visit https://www.biostars.org.
ggplot split jitter within grouped boxes by different variables

Hi all-

I am trying to make a boxplot with the jitter split into 3 categories within the 2 categories for box plots. My current code makes it three boxes and three shapes- I want three shapes (Status1) and two boxes (Status2).

AI_ELISA_sev <- ggboxplot(ELISAtot, x = "AntiIso", y = "Titer",color="black", fill="Status2", palette="jco", add = "jitter", shape = "Status1")+ theme(legend.position="right")

AI_ELISA_sevp <-AI_ELISA_sev + stat_compare_means(aes(group=Status2), hide.ns=TRUE, label="p.signif", size=10, method="t.test", label.y = 5.3) + ggtitle("Isotype Status Differences") + yscale("log10", .format=TRUE)+ labs(x ="", y = "Antibody titer \n(Reciprocal Dilution)")+ stat_compare_means(method = "t.test", label.y = 0, color="transparent")+stat_compare_means(method = "t.test", label.y = 5.5, color="transparent")+ theme(axis.text.x = element_text(angle = 90))

enter image description here

enter image description here Thanks!

jitter rstudio r ggplot

1 answer

I didn't rebuild your dataset, could you try the code below? I think it should work

ggplot(ELISAtot) + geom_boxplot(aes(x = "AntiIso", y = "Titer", fill="Status2")) + geom_jitter(aes(x = "AntiIso", y = "Titer", shape = "Status1"))

Log in to answer this question.