I try to draw a barplot grouped figure, but I can't, my error is,
"position_jitterdodge()
requires at least one aesthetic to dodge by". Can anyone help me? Here is the sample of my data and my try to draw barplot code. My expected output is sth like the graph below.
library(ggpubr)
d<-data.frame(Average=c(3,1.5,4, 6,
2,5.4,3.1,0.9,
4.6,3.3,2.8,1.9,
2.1,3.7,4.4,5.2),
Size=c("1750","1750","1750","1750",
"2000","2000","2000","2000",
"2500","2500","2500","2500",
"3000","3000","3000","3000"),
Group=c("P1","P1","P1","P1",
"S1","S1","S1","S1",
"P2","P2","P2","P2",
"S2","S2","S2","S2"))
ggbarplot(
d, x = "Size", y = "Average",
add = c("mean_sd", "jitter"),
add.params = list(shape = "supp"),
fill= "Group", palette = c("#807F7F", "#BF504D"),
position = position_dodge(0.8)
)
There are several issues with your code:
group
has 4 values with only 2 colors assigned.Otherwise your code should work:
Created on 2020-10-02 by the reprex package (v0.3.0)