0

I am trying to plot signal intensity per timepoint in a violinplot then adding box-plots to it, to give more info. The dataframe has data for two duplicates A and B. So far I managed to create the graph but the boxplot is not overlapping the violin there is a slight shift. Any suggestions how fix that please?

Violin_plot <- ggplot(DF_combine, aes(factor(Duplicate),x=Time, y=signal))+ 
              geom_violin(aes(fill=Duplicate),width=0.6,color="#535352")+
              geom_boxplot(aes(fill=Duplicate),color="#535352",width=0.2,notch = T) +
              scale_fill_brewer(palette="Blues")

current graph

Simon.S.A.
  • 6,240
  • 7
  • 22
  • 41
NyanCat
  • 1
  • 1
  • 3
    Try adding `position = position_dodge(0.9)` in both `geom_violin()` and `geom_boxplot()`. (The 0.9 modifies the width, you might have to drop the "width" arguments, I am not sure.) – Zoe Aug 18 '21 at 13:36
  • Thanks a lot. It worked and did not complain about the width arg. If I may ask why position dodge 0.9 ? – NyanCat Aug 18 '21 at 13:56
  • I also had a similar problem recently and someone suggested me to read this question: https://stackoverflow.com/questions/34889766/what-is-the-width-argument-in-position-dodge (although I did not have the time yet to read through it myself ;;) – Zoe Aug 19 '21 at 07:59

0 Answers0