I am trying to plot several variable in one boxplot for my paper but the box plots are overlapping and I couldn't find any solution for this problem.
here is my code:
<- ggplot (MetaNotOne.art1)+
<-geom_boxplot(aes(x=TISSUE,y=simpson.art1), width=0.5, position = "dodge") +
<- geom_boxplot(aes(x=TISSUE,y=shannon), width=0.5, position = "dodge")+
but it doesn't work and box plots of different variables are plotted on top of each other.
I read all the relevant pages in stack overflow and other websites, but nothing worked.
I also tried adding another layer of boxplot using another data frame which did not work...
could anyone please help me with this?
We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.
I think it's because you call geom_boxplot twice, so you generate 2 boxplots on top of each other, position dodge doesn't work, because they don't know each other.
Try to convert to long format, put both value columns (simpson.art1, shannon) into one (do you know how to use gather?) then it may work.